Home » C » Solved Programs » Conditional statements
C program on conditional statements (if, elseif, else)
Problem: For annual sports, class eleven students are divided into 3 groups. which is A, B & C. From Roll 1 to 30 is in group A, Roll 31 to 60 is in group B & Roll 61 to 100 is in group C. Create progragm in C which takes roll no as input from user and display their group they belong to.
/*
Example of Conditional Statement in C programming
1st Jun 2018
Chicago, USA
cppbuzz.com
*/
#include
int main()
{
int rollNO;
printf("\n Enter Roll No : ");
scanf("%d",&rollNO);
if(rollNO >=1 & rollNO <=30)
printf("\n Student belongs to group A");
else if(rollNO >=31 & rollNO <=60)
printf("\n Student belongs to group B");
else if(rollNO >=61 & rollNO <=100)
printf("\n Student belongs to group C");
else
printf("\n Roll No should be between 1 & 100");
return 0;
}
Output of program