SHARE
Share this content:

Area Program

 

These programs are very easy as they only needs formula and so you can execute it perfectly. I have taken an example of an area of the square program. Remember that always create the logic in your mind like I want the area of a square so I want to know the formula i.e. ‘side * side’, side is just one variable which multiplies by itself. This answer should be stored in another variable called ‘area’. Finally, I need to print ‘area’ value as output.

From above logic, you can easily code. Likewise, you can have the question like an area of a circle, the area of the triangle, the circumference of circle blah blah blah. All you need to concentrate on formula and your work is done.

 

#include <stdio.h>
#include <conio.h>

void main()
{
int a,area;

printf(“Enter the value of the side:”);
scanf(“%d”,&a);

area=a*a;

printf(“\n The Area of square is %d”,area);

getch();

}

 

Output:

Enter the value of the side:6

The Area of square is 36

 

Explanation: 

\n is used to write in new line. It just acts like enter key to go to new line.

Share this content:

LEAVE A REPLY

Please enter your comment!
Please enter your name here