C program to calculate and print area and perimeter of the square

Problem In Hand

C Program to calculate and print area and perimeter of square

Process and Solution Of Problem

Take input for side of square and store in a variable
calculate and store area of square in variable.
calculate and store perimeter of square in another variable.
further display area and perimeter

Program/Source Code

#include <stdio.h>
 int main()
     int s,a,p;
     printf("Enter side of square ");
     printf("Area = %d  perimeter = %d",a,p);
 return 0;

Program Explanation

On execution of the program

* user enteres the side of square and store in a variable “s”
* Calculation is performed and area is stored in a variable “a” i.e. a=s*s;
* Calculation is performed and perimeter is stored in variable “p” i.e. p=4*s;
* then the result area and perimeter is displayed on the screen


Enter side of square 5
Area = 25  perimeter = 20

You May Also Like:

C Program to find largest of 3 numbers
C Program to print table of a number
C program to check number is +ve, -ve or zero
C program to check number is prime number or not
C program to convert total inches to feet and inches.

<<< Previous: Sum , Product and Difference of two numbersArea and Perimeter of rectangle : Next >>>

All Programs      C Simple Programs      If Condition Programs      Switch Statement Programs      Loop Programs       Conversion Programs      Pattern Programs       Single Dimension Numeric Array programs       Double Dimension Numeric Array programs      Single Dimension Character Array programs


Technical Questions

Interview Questions

C Programming
C++ Programming
Class 11 (Python)
Class 12 (Python)
C Language
C++ Programming

C Interview Questions
C++ Interview Questions