Sunday, August 7, 2011

C Program to demonstrate use of goto statement


#include<stdio.h>
#include<conio.h>
#include<math.h>
void main()
{
double x,y;
int count;
count=1;
printf(" Enter FIVE real values in a LINE \n");
read:
 scanf("%lf",&x);
 if(x<0)
printf("Value - %d is negative \n",count);
 else
 {
 y=sqrt(x);
 printf("%lf\t %lf\n",x,y);
 }
 count=count+1;
 if(count<=5)
 goto read;
 printf("\n END of Computation ");
getch();
}

No comments:

Post a Comment