0

How to write c program to input week number and print weekday? by using If else.

29th Oct 2021, 7:42 AM
Keren May Maturan
1 Answer
0
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
29th Oct 2021, 9:39 AM
sree harsha
sree harsha - avatar