Square a number – C


#include<stdio.h>
int square (int x);
// function declared here//
int main()
{ 
// main function starts from here//
int m, n; // declaration of two variables m and n
printf("Enter the number to be squared"); // giving command to output the data
scanf("%d", &m); // feding in some input
n = square (m); // formurla declaration
printf("Square of number %d is %d ", m,n); // output 

}
int square(int x)
{
int p;
p = x * x;
return (p);
}

Scroll to top