You are on page 1of 12

1. 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.
#include<stdio.h>
int main()
{
int rameshsalary;
int dearnessallowence,houserentallowence,grosssalaray;
printf("Enter Ramesh basic salary = ");
scanf("%d",&rameshsalary);
dearnessallowence = rameshsalary*40/100;
houserentallowence = rameshsalary*20/100;
grosssalaray = rameshsalary+dearnessallowence+houserentallowence;
printf("\nRamesh Gross salary is %d",grosssalaray);
getch();
return 0;
}

Output

2. 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>
int main()
{
int dist_in_km,dist_in_meter;
float dist_in_feet,dist_in_inches,dist_in_centi;
printf("Enter the distance between two cities = ");
scanf("%d",&dist_in_km);
dist_in_meter = dist_in_km*1000;
dist_in_feet = dist_in_meter*3.28084;
dist_in_inches = dist_in_feet*12;
dist_in_centi = dist_in_inches*2.54;
printf("\nDistance in meters = %d meters",dist_in_meter);
printf("\nDistance in feet = %f feets",dist_in_feet);
printf("\nDistance in inches = %f inches",dist_in_inches);
printf("\nDistance in centimeters = %f cm",dist_in_centi);
getch();
return 0;
}

Output

3. 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.
#include<stdio.h>
int main ()
{
int s1,s2,s3,s4,s5,agg;
float per;
printf("enter marks of 5 subjects =\n");
scanf("%d%d%d%d%d",&s1,&s2,&s3,&s4,&s5);
agg=s1+s2+s3+s4+s5;
per=agg*100.0/500.0;

printf("aggraget marks abtain by student = %d\n",agg);


printf("percentage of student = %f%",per);
return 0;
}
Output

4. Temperature of a city in Fahrenheit degrees is input through the keyboard.

Write a program to convert this temperature into Centigrade degrees.

#include<stdio.h>
int main ()
{
float faht,centt;
printf("enter tamperature in farhate =");
scanf("%f",&faht);
centt=5.0/9.0*faht-32;
printf("tamperature in centgrade =%f",centt);
return 0;
}

Output
5. The length & breadth of a rectangle and radius of a circle are input through
the keyboard. Write a program to calculate the area & perimeter of the
rectangle, and the area & circumference of the circle.

#include<stdio.h>
int main ()
{
float rl,rb,ra,rp,cr,ca,cc;
printf("enter lenght of rectangle =");
scanf("%f",&rl);
printf("enter breth of rectangle =");
scanf("%f",&rb);
printf("enter radius of circle =");
scanf("%f",&cr);
ra=rl*rb;
rp=2*rl+rb;
ca=3.14159*cr*cr;
cc=2*3.14159*cr;
printf("\nArea of rectangle = %f\n",ra);
printf("preimeter of rectangle = %f\n",rp);
printf("area of circle = %f\n",ca);
printf("circumference of circle = %f\n",cc);
return 0;
}
OutPut

6. If a five digit number is input through the keyboard .Write a program


to calculate the sum of its digits.

#include<stdio.h>
int main ()
{
int enterednumber,sumofdigites,a,b,c,d,e,d1,d2,d3,d4,d5;
printf("enter any five digit number =");
scanf("%D",&enterednumber);
a=enterednumber/8;
d5=a%8;
b=a/8;
d4=b%8;
c=b/8;
d3=c%8;
d=c/8;
d2=d%8;
e=d/8;
d1=e%8;
sumofdigites=d1+d2+d3+d4+d5;
printf("\nsum of digites is = %d",sumofdigites);
return 0;
}

Output
7. If a five-digit number is input through the keyboard, write a program to
reverse the number.

#include<stdio.h>
int main ()
{
int enterednumber,a,b,c,d,e,d1,d2,d3,d4,d5;
printf("enter any five digit number =");
scanf("%d",&enterednumber);
a=enterednumber/10;
d5=enterednumber%10;
b=a/10;
d4=a%10;
c=b/10;
d3=b%10;
d=c/10;
d2=c%10;
e=d/10;
d1=d%10;
printf("\nreverse number is = %d%d%d%d%d",d5,d4,d3,d2,d1);
return 0;
}

Output
8. If a four-digit number is input through the keyboard, write a program to
obtain the sum of the first and last digit of this number.

#include<stdio.h>
int main ()
{
int enterednumber,sum,a,b,c,d,d1,d2,d3,d4;
printf("enter any four digit number =");
scanf("%d",&enterednumber);
a=enterednumber/10;
d4=enterednumber%10;
b=a/10;
d3=a%10;
c=b/10;
d2=b%10;
d=c/10;
d1=c%10;
sum=d1+d4;
printf("sum of 1ist and 4th digit is =%d",sum);
return 0;
}

Output
9. In a town, the percentage of men is 52. The percentage of total literacy is
48. If total percentage of literate men is 35 of the total population, write a
program to find the total number of illiterate men and women if the
population of the town is 80,000.

#include<stdio.h>
int main ()
{
float mper,wper,totlp,mlp,noim,noiw;
int totp=80000;
mper=totp*52.0/100.0;
wper=totp-mper;
totlp=totp*48.0/100.0;
mlp=totp*35.0/100.0;
noim=mper-mlp;
noiw=wper-(totlp-mlp);
printf("\n%f\n%f",noim,noiw);
return 0;
}

Output
10. A cashier has currency notes of denominations 10, 50 and 100. If the
amount to be withdrawn is input through the keyboard in hundreds, find
the total number of currency notes of each denomination the cashier will
have to give to the withdrawer.

#include<stdio.h>
int main ()
{
int amt,ten,fif,hun;
printf("enter ammount to be withdraw =");
scanf("%d",&amt);
ten=amt/10;
fif=amt/50;
hun=amt/100;
printf("the cashier will give you\n%d ten notes\nor\n%d fifty notes\nor\n%d hundred
notes",ten,fif,hun);
return 0;
}

Output
11. If the total selling price of 15 items and the total profit earned on them is
input through the keyboard, write a program to find the cost price of one
item

#include<stdio.h>
int main ()
{
int sp,tp,cp,cp1;
printf("enter total selling price of 15 items =");
scanf("%d",&sp);
printf("enter profit on selling 15 items =");
scanf("%d",&tp);
cp=sp-tp;
cp1=cp/15;
printf("cost price of one item is %d",cp1);
return 0;
}

OutPut
14. 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.

#include<stdio.h>
int main ()
{
int num,res;
printf("enter any five digit number =");
scanf("%d",&num);
res=num+11111;
printf("output is %d",res);
return 0;

Output

You might also like