Program to print the square of a number in c-language

Program to print the square of a number in c-language                           


                              Method-1

#include<stdio.h>
int main()
{
int x,y;
printf("Enter the number for square\n");
scanf("%d",&x);
y=(x*x);
printf ("Square of the number is=%d",y);
}

                        Method-2

 #include<stdio.h>
#include<math.h>
main()
{
int x,y;
printf("Enter the number for square\n");
scanf("%d",&x);
y=pow(x,2);
printf ("Square of the number is=%d",y);
}

OUTPUT
Enter the number for square
5
Square of the number=25

This program is perfect example of pow function and also describe the math.h header files.
By using this function you can find any power of any number.
But in this program pow used for calculating square

If you like this program then you can share it and for any issues you can direct contact with me from Home Page.

For regular updates you can also follow my site.

Comments

Popular posts

Creative pattern of butterfly in C-language

Syntax of C-language

Variable & Datatype for C-programming

Language Translator of C-language

Errors in C-language

Addition of two numbers in c language

Introduction of C-language.

Linear search in C-language

Binary searching in C-language

Program to reverse one array into other array in C-language