CHAPTER 4
May 20, 2011(1) %d :- It is use for integer value
(1) %f :- It is use for float value
printf() has two syntax :-
(i) printf(" Messege ") :- It is use two print any text
(ii) printf("%d / %f",variable); :- Two print values of variable
/* Program to explain use of float */
main()
{
float a;
clrscr();
a=5/2;
printf("a=%f",a);
getch();
}
OUTPUT
a=2.0
In this program if we divide any integer value
with another integer value than answer will be in decimal but it will
not correct like above example.
To solve this problem one number should be float.
/* Program to explain use of float */
main()
{
float a;
clrscr();
a=5.0/2;
printf("a=%f",a);
getch();
}
OUTPUT
a=2.5
/* Program to find area of circle*/
main()
{
float a,r;
clrscr();
printf("Enter radius of circle ");
scanf("%f",&r);
a=3.141 * r * r;
printf("Area is %f",a);
getch();
}
OUTPUT
Enter radius of circle 2
Area is 8.564
QUESTION
Write a program to input principle,rate,time and calculate simple interest ?
Posted by Rishi Shrivastava.