Translate

Sunday, May 10, 2020

C Program to Print Day Name of Week using Switch Statements

#include<stdio.h>
#include<stdio.h>
void main()
{
     int ch;
    printf("\n1. press ch=1 for monday. \n2. press ch=2 for tuesday.\n3. press ch=3 for wednesday. \n4.press ch=4 for thursday. \n5.press ch=5 for friday.\n6.press ch=6 for saturday. \n7. press ch=7 for sunday.");

    printf("\n enetr your choice =");
    scanf("%d", &ch);
   
 switch(ch)
     {

        case 1:
        printf("today is monday");
        break;
        
        case 2:
        printf("today is tuesday");
        break;
        
        case 3:
        printf("today is wednesday");
        break;
  
        case 4:
        printf("today is thursday");
        break;
        
        case 5:
        printf("today is friday");
        break;
  
        case 6:
        printf("today is saturday");
        break;
        
        case 7:
        printf("today is sunday");
        break;
        
        default:
        printf("wrong choice Try Again!!!");
     }
        
    getch();

}

Output:

No comments:

Post a Comment

C program to make a calculator using the switch statement.

/*perform arithmetic calculation on integers in C language*/ #include<stdio.h> #include<conio.h> void main() {     char op;     ...