Q:

C Program to calculate the square of a number using a function

0

C Program to calculate the square of a number using a function

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

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

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

This question belongs to these collections

Similar questions


need a help?


find thousands of online teachers now