C program to find area of square using default argument:
Hello , Learner welcome you on my blog. Today we are going to describe a 'C' program to calculate area of a square by using default argument.
Now as we know that the area of square can be calculated by multiplying its side ('In a square length = Breadth'). i.e If length and breadth of a square is "a" , then the area of a square will be "a x a" .
Suppose "a = 7 mm" then the area that of square = 7 x 7 = 49 mm^2".
Now We write a code in C programming language to find the area of square by using default argument.
C Code to calculate Area of Square:
#include<stdio.h>
int main(){
float SquareSide , AreaOfSquare; // variable declaration;
printf("Enter Side of Square: \n"); // ask for user input;
scanf("%f", &SquareSide); // take user input
AreaOfSquare = SquareSide * SquareSide; // calculate area;
printf("Area of square : %f", AreaOfSquare); // display area;
return 0;
}
Output for the above program;
Enter Side of Square:
8
Area of square : 64.0000
Feel free to comment.
0 comments:
Post a Comment