38-Write a C program to calculate the square of a number using function.

Program: 38

Write a C program to display whether number is prime or not (while-loop).

#include
#include
float square(float);
int main()
{
    float a, b;
    printf("Enter any number: ");
    scanf("%f", &a);
    b=square(a);
    printf("Square of %f is %f\n",a,b);
    getch();
}

float square (float x)

{

    float y;

    y=x*x;

    return(y);

}
Output
Enter any number: 5

Square of 5.000000 is 25.000000

Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.