All the Notes in one Place. Download our Official App from Google Play.

C Programs Page 2

C Programs Page 2

C Programs Page 2

To view other topics related to Computer. Click Here.

Program to compute the distance covered by a car in 50 seconds. The initial velocity is m/sec and acceleration is 5m/sec^2. Use formula s=vit+1/2 at^2

main( )

{

int t,vi,a;

double s;

t=50;

vi=10;

a=5;

s=vi*t+0.5*a*t*t;

clrscr ();

printf(“Distance Covered =%f m”,s);

}

If a five digit number is input through the keyboard, write a program to reverse the number

main( )

{

int n,r;

printf(“/n Enter a number”);

scanf(“%d”, &n);

Printf(“/n The number in revers”);

r= n%10;

n=n/10;

printf(“Reminder=%d”,r);

r=n%10;

n=n/10;

printf(“Reminder=%d”,r);

r=n%10;

n=n/10;

printf(“Reminder=%d”,r);

r=n %10;

n=n /10;

printf(“Reminder of r % d Reminder of n %d”,r,n);

}

Temperature of a city in Fahrenheit degrees is input through the keyboard. Write a program to convert this temperature into centigrade degrees.

main( )

{

float f,c;

printf(“/n Enter temperature”);

scanf(“%f”,&f);

c=5.0/9.0*(f-32.0);

printf(“/n f=%f /t c=%f, fc);

}

Find out the aggregate marks and percentage marks obtained by the student. Assume that the maximum marks that con be obtained in each subject is 100

Main( )

{

int m1,m2,m3,m4,m5, sum;

float agg,per;

printf(“/n Enter the marks of five subjects”);

scanf(“% d % d % d %d % d “,&m1,&m2,&m3,&m4,&m5);

sum=m1+m2+m3+m4+m5;

agg=sum/5.0;

per=sum*100.0/500.0;

printf(“/n percentage =%f”,per);

}

Write a program to input the age of a person in years. Convert the age into months and days and print the result in the center of the screen

main( )

{

long int age, mon, day;

clrscr();

printf(“Enter age in years?”);

scanf(“%d”,&age);

mon=age * 12;

days= age *365;

gotoxy(365,12);

printf(“Age in days=%d”, days);

}

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

main( )

{

int n,sum ,fd,ld;

Printf(“/n Enter the four digit number”);

Scanf(“%d”,&N);

Id=n%10;

Fd=n/1000;

Printf(“/n First digit is%d and last digit is “,fd,id);

Sum=fd+id;

Printf(“/n Sum of first and last digit =%d”,sum);

}

Write a program to calculate the area & perimeter of the rectangle, and the area of circumference of the circle

Main( )

{

int len, wid, r;

float por, aoc, coc;

float pi=3.1417;

printf(“/n Enter the value of length, width &radius “);

scanf(“%d %d %d “,&len, &wid, &r);

por=2*(len+wid);

aor=len+wid;

aoc=pi*r*r;

coc=2*pi*r;

prontf(“/n perimeter of rectangle is % f”,por);

Printf(“/n area of rectangle is %f”,aor);

Printf(“/n arear of circle is %f”,aoc);

Printf (“/n circumference of circle id %f”, coc);

}

The distances between two cities (in km)is input through the keyboard write a program to convert and print this distance

main( )

{

float km,m ,ft,inc,cm;

printf(“/nEnter the distance b/w two cities in km”);

scanf(“%f”,&km);

m=km*1000;

cm=m*100;

inc=cm/2.54;

ft=inc/12

printf(“/n meter=%f/n centimeter/n %f”,m,cm);

printf(“/n inches=%f/n feet /n %f”,inc,ft);

}

Nawaz basic salary is input through the keyboard. His dearness allowances us 40% of basic salary. Write a program to calculate his gross salary

main( )

{

int b_pay;

float d all.h rent, g_pay

printf(“/nEnter The Basic Salary Of Employer”);

scanf(“%d%d”,&b,&pay”);

d_all=b_pay*40.0/100.0

g_pay=b_pay+d_all+h_rent;

Prnitf(“Gross salary of employer is= %f”,g_pay);

}

Post a Comment

Previous Post Next Post