Saturday, May 21, 2016

A Program in C using DO-WHILE Loop to find square of the number

Program code:

#include<stdio.h>
#include<conio.h>
int main()
{
int num,op;
//clrscr();
do
{
printf("enter a number:\n");
scanf("%d",&num);
printf("square root of %d is %d\n",num,num*num);
printf("want to try another number? \n(enter 1 for yes /0 for no)\n");
scanf("%d",&op);
}
while(op==1);
//getch();
return 0;
}

output:

enter a number:
2
square root of 2 is 4
want to try another number?
(enter 1 for yes/0 for no)
n

No comments:

Post a Comment