Sunday 11 December 2011

Write a program to print square of input number given by user in c

#include
#include
main()
{
int num,square;
char ans='y';
clrscr();
while(ans=='y'||ans=='Y')
{
printf("Enter a number\n");
scanf("%d",&num);
square=num*num;
printf("The square of %d is %d",num,square);
printf("\nDo You wish to enter another number (y for yes):");
fflush(stdin);
scanf("%c",&ans);
}
getch();
}


OUTPUT

Enter a number : 7
The square of 7 is 49
Do You wish to enter another number (y for yes):

No comments:

Post a Comment