Program 5

Write a C program to find out distance travelled by the equation d = ut + 1/2(at^2)

#include<stdio.h>
void main()
{
int u,t,a,d;
     u=5;
     t=8;
     a=10;
   
d=u*t+(a*t*t)/2;

printf(“value of distance travelled:%d”,d);

return 0;
}

Output

value of distance travelled:360

Program 4

Write a C program to enter a distance into kilometre and convert it in to meter, feet, inches and
centimetre

#include<stdio.h>
void main()
{
float km,m,f,in,cm;
printf(“Enter distance in kilometer”);
scanf(“%f”,&km);

m= km*1000;
f= km*3280.84;
in= km*39370.08;
cm= km*1000*100;

printf(“the distance in meter=%f\n”,m);
printf(“the distance in feet=%f\n”,f);
printf(“the distance in inches=%f\n”,in);
printf(“the distance in centimeters=%f\n”,cm);

return 0;
}

Output

Enter distance in kilometer = 2
the distance in meter=2000.000000
the distance in feet=6561.680176
the distance in inches=78740.156250
the distance in centimeters=200000.000000

Program 3

Write a C program to interchange two numbers.

#include<stdio.h>
void main()
{
int a,b;
     a=10;
     b=20;

printf(“value of a before iuterchange =%d\n”,a);
printf(“value of a before iuterchange =%d\n”,b);

a+=b;
b=a-b;
a=a-b;

printf(“value of a after iuterchange =%d\n”,a);
printf(“value of a after iuterchange =%d\n”,b);

return 0;
}

Output

value of a before iuterchange =10
value of a before iuterchange =20
value of a after iuterchange =20
value of a after iuterchange =10

Program 2

Write a program to calculate simple interest (i = (prn)/100 )
i = Simple interest
p = Principal amount
r = Rate of interest
n = Number of years

#include<stdio.h>
void main()
{
int p=1000;
int n=7;
float r=8.5;
float i;

i=(p*r*n)/100;

printf(“simple intrest=%f”,i);

}

Output

simple intrest=595.000000

Program  1    

Write a program which performs as simple calculator (addition, multiplication, division,
subtraction).

#include<stdio.h>
int main()
{
int a,b;
a=100;
b=50;

printf(“a+b :%d\n”,a+b);
printf(“a*b :%d\n”,a*b);
printf(“a-b :%d\n”,a-b);
printf(“a/b :%d\n”,a/b);
return 0;
}

Design a site like this with WordPress.com
Get started