C Function which prints square of given number.

//C Function which prints square of given number.


#include <stdio.h>

int sqr(int a);

int main()
{
	int a,ans;
	printf("Enter a digit to find square : ");
	scanf("%d",&a);
	ans=sqr(a);
	printf("\n\nSquare of %d : %d",a,ans);
	return 0;
}

int sqr(int a)
{
	int ans;
	ans=a*a;
	return ans;
}

Output :
Enter a digit to find square : 5

Square of 5 : 25



Leave a comment