Lets write a C program to find area of a square by using length of its side. We ask the user to input the length of its side.
Page Contents
area = side x side.
Note: All the sides of a square are equal.
User Input:
Enter the length of side of a square
5
Output:
Area of the Square is 25.00
Video Tutorial: C Program To Calculate Area of a Square using its Side
#include < stdio.h > int main() { float area, side; printf("Enter the length of side of a square\n"); scanf("%f", &side); area = side * side; printf("Area of the Square is %0.2f \n", area); return 0; }
Output 1:
Enter the length of side of a square
3
Area of the Square is 9.00
Output 2:
Enter the length of side of a square
4
Area of the Square is 16.00
Output 3:
Enter the length of side of a square
5
Area of the Square is 25.00
Output 4:
Enter the length of side of a square
6
Area of the Square is 36.00
Output 5:
Enter the length of side of a square
8
Area of the Square is 64.00
For list of all c programming interviews / viva question and answers visit: C Programming Interview / Viva Q&A List
For full C programming language free video tutorial list visit:C Programming: Beginner To Advance To Expert