forked from gouravthakur39/beginners-C-program-examples
-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathGotoStatementEvenOrOdd.c
More file actions
38 lines (35 loc) · 824 Bytes
/
GotoStatementEvenOrOdd.c
File metadata and controls
38 lines (35 loc) · 824 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// Program to input an integer number and check whether it is
//even or odd and positive or negative using goto statements
#include <stdio.h>
int main() {
int n;
printf("enter a number\n");
scanf("%d", & n);
if (n % 2 == 0 && n > 0)
goto a;
else if (n % 2 != 0 && n < 0)
goto b;
else if (n % 2 == 0 && n < 0)
goto c;
else if (n % 2 != 0 && n > 0)
goto d;
else
goto e;
a:
printf("number is even and positive");
goto stop;
b:
printf("number is odd and negative");
goto stop;
c:
printf("number is even and negative");
goto stop;
d:
printf("number is odd and positive");
goto stop;
e:
printf("special number");
goto stop;
stop:
return 0;
}