Pages

Monday, June 27, 2011

Distance Converter Program(Ref: Let us c-chapter1)
This program converts the entered value into meters,feet,inches and centimeters

The distance between two cities (in km) is input through the keyboard. Write a program to convert and print this distance in meters,feet,inches and centimeters.

#include<stdio.h>

/*
1 kilometer=39370 inches
1 kilometer=3281 Feet
1 kilometer=100000 centimeters
1 kilometer=1000 meters

*/

void main()
{
float km,meter,feet,inches,centimeter;
clrscr();
printf("Enter the distance between two cities:");
scanf("%f",&km);

meter=1000*km;
centimeter=100000*km;
inches=39370*km;
feet=3281*km;

printf("\nThe Entered distance between two cities in meter is:%f",meter);
printf("\nThe Entered distance between two cities in centimeter is:%f",centimeter);
printf("\nThe Entered distance between two cities in inches is:%f",inches);
printf("\nThe Entered distance between two cities in feet is:%f",feet);

getch();
}
Gross Salary Program(Ref: Let us c-chapter1)

This program calculate gross salary of an employee if his basic slaray is input thru keyboard.


Ramesh's basic salary is input throught the keyboard.His dearness allowance is 40% of basic salary,and house rent allowance is 20% of basic salary.Write a program to calclate gross salary.

#include<stdio.h>
void main()
{

float bs,gs,hra,da;
clrscr();
printf("Enter basic salary:");
scanf("%f",&bs);
hra=bs*20/100;
da=bs*40/100;
gs=bs+hra+da;
printf("Gross salary= %f",gs);
getch();
}