Google Ads

Saturday, May 30, 2009

Finding Square Root

#include”stdio.h”
#include”conio.h”
#include"math.h"

void main()
{
int count=1;
float x,y;
clrscr();
printf("Enter 5 value: ");
read:
scanf("%f",&x);
if(x<0)
printf("value %d is negative\n",count);
else
{
y=sqrt(x);
printf("Sqrt of %f is %f\n",x,y);
}
count++;
if(count<=5)
goto read;
getch();
}


OUTPUT WILL BE


Enter 5 value:
4 6 9 -10 16

Sqrt of 4.000000 is 2.000000
Sqrt of 6.000000 is 2.449490
Sqrt of 9.000000 is 3.000000
value 4 is negative
Sqrt of 16.000000 is 4.000000

No comments:

Post a Comment