Skip to content

Instantly share code, notes, and snippets.

@btechmag
Created April 29, 2021 07:46
Show Gist options
  • Save btechmag/89eeaa2928030c1e1cce79dd477cbe66 to your computer and use it in GitHub Desktop.
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.
#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