New course! Every coder should learn Generative AI!
Try a free lesson0
void main()
{
int x;
printf(“Enter week number :”);
scanf(“%d”,&x);
if(x==0)
printf(“Sunday”);
else if(x==1)
printf(“Monday”);
else if(x==2)
printf(“Tuesday”);
else if(x==3)
printf(“Wednesday”);
else if(x==4)
printf(“Thursday”);
else if(x==5)
printf(“Friday”);
else if(x==6)
printf(“Saturday”);
else
printf(“No day”);
}
Explaining
The above program is working based on ladder if
Every “if” is a condition
Stating from 0 to 6 valid input and valid days
Finally “else” represents if none of the conditions are satisfying
Means more than 6 or less than 0 no day is available