Write a program in C to find the square of any number using the function.
Test Data :
Input any number for square : 20
Expected Output :
The square of 20 is : 400.00
Problem from (w3resource.com)
SOLUTION:
#include <stdio.h>
#include <math.h>
void squareOfNum(double n){
double result = pow(n, 2);
printf(“The square of %d is: %lf”, n, result);
}
int main() {
int n = 0.0;
printf(“Enter a number to square:\n”);
scanf(“%d”, &n);
squareOfNum(n);
return 0;
}