Write a program to determine the type of berth when the seat/berth number in the train is given. Input Format: Input consists of a single integer. Assume that the range of input is between 1 and 72. Output Format: Output consists of a single string. [Upper or Middle or Lower or Side Lower or Side Upper] Sample Input 1: 9 Sample Output 1: Lower Sample Input 2: 72 Sample Output 2: Side Upper
#include<stdio.h> #include<string.h> int main(){ int n,k; scanf("%d",&n); k=n%8; if(k==1 || k==4) printf("Lower"); if(k==2 || k==5) printf("Middle"); if(k==3 || k==6) printf("Upper"); if (k==0) printf("Side Upper"); if(k==7) printf("Side Lower"); return 0; }