Print the square of the number in C


Levels of difficulty: / perform operation:

C program to ask the user for a number. Print the square of the number and ask a confirmation from the user whether the user want to continue or not.

C Program

#include <stdio.h>
#include <conio.h>
void main()
{
	char ch='y';
	int num;
	clrscr();
	while (ch=='y'|| ch=='Y')
        {
		printf("\nENTER A NUMBER: ");
		scanf("%d",&num);
		printf("\nITS SQUARE IS: %d\n",num*num);
		printf("\nDO YOU WANT TO CONTINUE [Y/N]: ");
		ch=getche();
	}
	getch();
}


Output







Quantitative Aptitude
Reasoning
Programming
Interview