├── booked seat numbers with its located place ├── calculate the days of the month ├── find amestrong number ├── given is digit or character └── voting age /booked seat numbers with its located place: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | int main() 4 | { 5 | int n; 6 | printf("enter the number:"); 7 | scanf("%d",&n); 8 | if(n>=1 && n<=72){ 9 | switch(n%8) 10 | { 11 | case 0: 12 | printf("side upper\n"); 13 | break; 14 | case 1: 15 | printf("lower\n"); 16 | break; 17 | case 2: 18 | printf("middle\n"); 19 | break; 20 | case 3: 21 | printf("upper\n"); 22 | break; 23 | case 4: 24 | printf("lower\n"); 25 | break; 26 | case 5: 27 | printf("middle\n"); 28 | break; 29 | case 6: 30 | printf("upper\n"); 31 | break; 32 | case 7: 33 | printf("side lower\n"); 34 | break;}} 35 | else{ 36 | printf("invalid"); 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /calculate the days of the month: -------------------------------------------------------------------------------- 1 | #include 2 | int main() { 3 | int month; 4 | int year; 5 | printf("Enter the year: "); 6 | scanf("%d", &year); 7 | printf("Enter the month (1-12): "); 8 | scanf("%d", &month); 9 | if (month < 1 || month > 12) { 10 | printf("Invalid month\n"); 11 | return 1;} 12 | if (month == 1 || month == 3 || month == 5 || month == 7 || month == 8 || month == 10 || month == 12) { 13 | printf(" 31 days\n", month, year); 14 | printf("valid month\n"); 15 | } else if (month == 4 || month == 6 || month == 9 || month == 11) { 16 | printf(" 30 days\n", month, year); 17 | printf("valid month\n"); 18 | } else if (month == 2) { 19 | if ((year % 4 == 0 && year % 100 != 0) || (year % 400 == 0)) { 20 | printf(" 29 days (leap year)\n", month, year); 21 | } else { 22 | printf(" 28 days(not a leap year)\n", month, year); 23 | }printf("valid month\n"); 24 | } 25 | return 0; 26 | } 27 | -------------------------------------------------------------------------------- /find amestrong number: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int n=1; 4 | while(n<10000000){ 5 | int a[n]; 6 | int sum=0; 7 | int c=0; 8 | int t1=n; 9 | int t2=n; 10 | while(n!=0){c++; 11 | n=n/10; 12 | } 13 | while(t1!=0){ 14 | int l=t1%10; 15 | int p=1; 16 | int f=c; 17 | while(f!=0){ 18 | p=p*l; 19 | f--; 20 | } 21 | t1=t1/10; 22 | sum=sum+p; 23 | }if(sum==t2) 24 | { 25 | printf("%d \n",t2); 26 | } 27 | n=t2; 28 | n++; 29 | } 30 | return 0; 31 | } 32 | -------------------------------------------------------------------------------- /given is digit or character: -------------------------------------------------------------------------------- 1 | 2 | #include 3 | int main (){ 4 | int a; 5 | scanf("%d",&a); 6 | char b[1000]; 7 | if(a==b[1000]) 8 | { 9 | printf("the given is character\n"); 10 | } 11 | else{ 12 | printf("the given is digit\n"); 13 | } 14 | return 0; 15 | } 16 | -------------------------------------------------------------------------------- /voting age: -------------------------------------------------------------------------------- 1 | #include 2 | int main(){ 3 | int age; 4 | char a[100]; 5 | scanf("%s%d",&a,&age); 6 | printf("name:%s\n",a); 7 | printf("age:%d\n",age); 8 | if(age>18){ 9 | printf("ELIGIBLE TO VOTE\n"); 10 | } 11 | else{ 12 | printf("NOT ELIGIBLE TO VOTE\n"); 13 | } 14 | return 0; 15 | } 16 | --------------------------------------------------------------------------------