Last active
December 13, 2019 13:20
-
-
Save oykelrae/5d6671f74f74be7d2d02cd0c81333b46 to your computer and use it in GitHub Desktop.
Switch statement. "Whether a entered number is divisible by 6" program
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int main(void) { | |
printf("Let's see if your number is divisible by 6.\nEnter a number: "); | |
int num; | |
scanf("%d",&num); | |
switch (num%3) { | |
case 0 : | |
switch (num%2) { | |
case 0 : printf("YES\n"); break; | |
case 1 : printf("NO\n"); break; | |
} | |
break; | |
case 1 : | |
case 2 : printf("NO\n\n"); break; | |
} | |
return 0; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Let's see if your number is divisible by 6. | |
Enter a number: 136 | |
NO | |
Program ended with exit code: 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This program was created based on the listing 7 from YoungCoder.ru: http://youngcoder.ru/lessons/6/switch.php.