Pages

Wednesday, July 31, 2013

[H]. (a) Ramesh’s basic salary is input through the keyboard. His dearness allowance is 40% of basic salary, and house rent allowance is 20% of basic salary. Write a program to calculate his gross salary.

void main()
{
float bSal, da, hra, gSal;
clrscr();
printf("Enter Your Basic Salary : ");
scanf("%f",&bSal);
da=bSal*0.4;
hra=bSal*0.2;
gSal=bSal+da+hra;
printf("Gross Salary = %f",gSal);
getch();
}

Tuesday, July 30, 2013

[H]. (b) 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.

void main()
{
double km, m, ft, inch, cm;
clrscr();
printf("Enter Distance Between Two City in Kilometer : ");
scanf("%lf",&km);
m=km*1000;
ft=km*3280.8399;
inch=km*39370.0787;
cm=km*100000;
printf("\n%lf Kilometer = %lf Meter",km,m);
printf("\n%lf Kilometer = %lf Feet",km,ft);
printf("\n%lf Kilometer = %lf Inch",km,inch);
printf("\n%lf Kilometer = %lf Centimeter",km,cm);
getch();
}

Monday, July 29, 2013

[H]. (c) If the marks obtained by a student in five different subjects are input through the keyboard, find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that can be obtained by a student in each subject is 100.

void main()
{
int math, sci, sst, hin, eng, agg;
float percent;
printf("Maximum Marks In One Subjet Is 100.");
printf("\nEnter Marks Of Mathematics : ");
scanf("%d",&math);
printf("Enter Marks Of Science : ");
scanf("%d",&sci);
printf("Enter Marks Of Social Studies : ");
scanf("%d",&sst);
printf("Enter Marks Of Hindi : ");
scanf("%d",&hin);
printf("Enter Marks Of English : ");
scanf("%d",&eng);
agg=math+sci+sst+hin+eng;
percent=agg/5;
printf("Aggregate Marks = %d",agg);
printf("\nPercent = %f",percent);
getch();
}

Friday, July 19, 2013

[H]. (m) If a five-digit number is input through the keyboard, write a program to print a new number by adding one to each of its digits. For example if the number that is input is 12391 then the output should be displayed as 23402.

void main()
{
int a, b, c, d, e;
long num;
clrscr();
printf("Enter Five Digit Number : ");
scanf("%ld",&num);
e=num%10;
num=num/10;
d=num%10;
num=num/10;
c=num%10;
num=num/10;
b=num%10;
num=num/10;
a=num%10;
a=a+1;
b=b+1;
c=c+1;
d=d+1;
e=e+1;
a=a%10;
b=b%10;
c=c%10;
d=d%10;
e=e%10;
printf("New Number = %d%d%d%d%d",a,b,c,d,e);
getch();
}