initial import
[staff/goc4/2018bti7061.git] / c-2-controlStructures / examples / controlStatements / goto.c
1 #include <stdio.h>
2 #include <math.h>
3 main(){
4 puts("--------------------------");
5 puts("Examples with CONTINUE");
6
7 int i,val;
8
9 for(i=0; i< 10; i++){
10 puts("Type a number:");
11 scanf("%d",&val);
12 if(val<0){ /* A negative number does not have a sqrt*/
13 goto errorNegativeNumber;
14 }
15 double res = sqrt(val*1.0);
16 printf("Square root of %d is %lg\n",val,res);
17
18 }
19
20 return;
21
22 errorNegativeNumber:
23 printf("Negative number do not have any square root\n");
24 return;
25
26 }