The below program ask the user to enter the value. After getting the value from the user it will call a function squareOfNumber() to calculate the square of the entered number. The function squareOfNumber() is using an arithmetic multiplication operator to calculate the square of the input number.
#include<stdio.h>
//function to calculate square of number
float squareOfNumber(float num)
{
return (num*num);
}
int main()
{
float number, square;
printf("Please Enter any integer Value : ");
scanf("%f", &number);
square = squareOfNumber(number);
printf("square of a given number %.2f is = %.2f", number, square);
return 0;
}
Output:
Please Enter any integer Value : 4.5 square of a given number 4.50 is = 20.25
The below program ask the user to enter the value. After getting the value from the user it will call a function squareOfNumber() to calculate the square of the entered number. The function squareOfNumber() is using an arithmetic multiplication operator to calculate the square of the input number.
Output:
Please Enter any integer Value : 4.5
need an explanation for this answer? contact us directly to get an explanation for this answersquare of a given number 4.50 is = 20.25