SHOW:
|
|
- or go back to the newest paste.
| 1 | /* C programme to check if a integer is even or odd */ | |
| 2 | #include<stdio.h> | |
| 3 | int main(void) | |
| 4 | {
| |
| 5 | int a; | |
| 6 | printf("enter a number to test whether it is positive or not\n");
| |
| 7 | scanf("%d",&a);
| |
| 8 | if(a==0) | |
| 9 | {
| |
| 10 | printf("zero\n");
| |
| 11 | } | |
| 12 | else if(a%2==0) | |
| 13 | {
| |
| 14 | printf("even\n");
| |
| 15 | } | |
| 16 | else | |
| 17 | {
| |
| 18 | printf("odd\n");
| |
| 19 | } | |
| 20 | return 0; | |
| 21 | } |