C Program to find square of a number

Category: C ProgramTags: cprogram function

C Program to fine square of a number

C Program to find square of a number using function

#include <stdio.h>

float square(float num);

void main()
{
    float num, result;
    printf("Enter number: ");
    scanf("%f", &num);

    result = square(num);
    printf("Square of %0.2f is %0.2f", num, result);
}

float square(float num)
{
    return num * num;
}

Output

Output

Enter number: 2
Square of 2 is 4