Programming Example
Program to find area and circumference of circle.
This program calculates area and circumference of a circle.
/* Documentation Section
program: Program to find area and circumference of circle.
author: atnyla developer
*/
#include<stdio.h>
#include<conio.h>
void main()
{
int r;
float pi=3.14,area,ci;
printf("enter radius of circle: \n");
scanf("%d",&r);
area=pi*r*r;
printf("area of circle=%f \n",area);
ci=2*pi*r;
printf("circumference=%f \n",ci);
}
enter radius of circle:
5
area of circle=78.500000
circumference=31.400002
Press any key to continue . . .
First read the algorithm, then study the program code line by line. After that, compare the code with the output and finally go through the explanation. This approach helps learners understand both the logic and the implementation properly.
After understanding this example, try to rewrite the same program without looking at the code. Then change some values or logic and run it again. This helps improve confidence and keeps learners engaged on the page for longer.