[ We have learnt how to install the IDE and to do the programs already. If any doubts visit my first Program.]
CODING:
#include<stdio.h>
main()
{
float area, radius,circum;
printf("\n");
printf("Enter the radius: ");
scanf("%f",&radius);
circum = 2.0*22.0/7.0*radius;
area = 22.0/7.0*radius*radius;
printf("AREA AND CIRCUMFERENCE OF A CIRCLE");
printf("\n*********************************");
printf("\n\n");
printf("The radius is %5.2f", radius);
printf("\n\n");
printf("The Area is %5.2f", area);
printf("\n\n");
printf("The Circumference is %5.2f", circum);
printf("\n\n");
getch();
}
main()
{
float area, radius,circum;
printf("\n");
printf("Enter the radius: ");
scanf("%f",&radius);
circum = 2.0*22.0/7.0*radius;
area = 22.0/7.0*radius*radius;
printf("AREA AND CIRCUMFERENCE OF A CIRCLE");
printf("\n*********************************");
printf("\n\n");
printf("The radius is %5.2f", radius);
printf("\n\n");
printf("The Area is %5.2f", area);
printf("\n\n");
printf("The Circumference is %5.2f", circum);
printf("\n\n");
getch();
}
OUTPUT:
EXPLANATION:
First, the variables has been declared as float type. we have to use scanf method to read the value and the data type has to be given as %f. Formula for area of a circle is
π×(radius)2 and for circumference is 2 π×r.
getch() is a function which has its protype defined in conio.h header file.
it is basically used to take input a single character from keyboard and this char is not displayed at the screen.
it waits until itn gets a input that's why it can be used as a screen stopper.
π×(radius)2 and for circumference is 2 π×r.
getch() is a function which has its protype defined in conio.h header file.
it is basically used to take input a single character from keyboard and this char is not displayed at the screen.
it waits until itn gets a input that's why it can be used as a screen stopper.
No comments:
Post a Comment