Created
April 29, 2021 07:46
-
-
Save btechmag/89eeaa2928030c1e1cce79dd477cbe66 to your computer and use it in GitHub Desktop.
C Program to read an integer from the keyboard and check the specified range where it belongs.
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() | |
{ | |
//Program to read an integer from the keyboard and check the specified range where it belongs | |
int x; | |
printf("Input an integer: "); | |
scanf("%d", &x); | |
if(x >= 0 && x <= 20) | |
{ | |
printf("Range [0, 20]"); | |
} | |
else if(x >= 21 && x <= 40) | |
{ | |
printf("Range [21, 40]"); | |
} | |
else if(x >= 41 && x <= 60) | |
{ | |
printf("Range [41, 60]"); | |
} | |
else if(x >= 61 && x <= 80) | |
{ | |
printf("Range [61, 80]"); | |
} | |
else | |
{ | |
printf("Outside the range"); | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment