Simple C Program for Switch case to Find weekdays name with weekday number
Definition
In c programming language, switch statement is a type of selection mechanism used to allow block code among many alternatives.
Simply,It changes the control flow of program execution via a mutliple block. we can use for Nested if.. else statement.
Syntax:
switch ( <variable> ) {
case value1:
//Block 1 Code Here
break;
case value2:
//Block 1 Code Here
break;
...
default:
Code to execute for not match case
break;
}
Simple C Program for Switch case to Find weekdays name with weekday number
/*## Simple C Program for Switch case to Find weekdays name with weekday number */
/*## Basic Programs,Find weekdays C Programming*/
#include <stdio.h>
int main() {
// Declare Variables
int day;
//Read Day Value
printf("Enter weekday number (1-7): ");
scanf("%d",&day);
//Print Day with Switch case
switch(day)
{
case 1:
printf("1 - Sunday");
break;
case 2:
printf("2 - Monday");
break;
case 3:
printf("3 - Tuesday");
break;
case 4:
printf("4 - Wednesday");
break;
case 5:
printf("5 - Thursday");
break;
case 6:
printf("6 - Friday");
break;
case 7:
printf("7 - Saturday");
break;
default:
printf("%d : Invalid Day Option",day);
}
return 0;
}
Sample Output:
Enter weekday number (1-7): 4
4 - Wednesday
Enter weekday number (1-7): 10
10 : Invalid Day Option
Simple Example Programs In C Language
- Hello World C Language Example Program
- If Statement Example Program In C Programming Language
- If else Statement Example Program In C Programming Language
- Simple Example Program For If..Else : Example 2
- Switch Case Statement Example Program In C Programming Language
- Simple Example Program For Printf
- Simple C Program for Switch case to Find weekdays name with weekday number
- Simple Program to Print All ASCII Value Table in C Programming
Read More Articles
- Use of getch(),getche() and getchar() in C
- Switch Case Statement Example Program In C Programming Language
- C Character Set
- Convert a Floating-point value to an Integer in C
- Data Input and Output gets and puts Example Program In C
- Special Operators In C
- Pointer Representation and Pointer Example Programs
- C Data Input and Data Output
- Simple While Loop Example Program In C Programming Language
- Data Output printf and putchar Example Program In C
- C Introduction
- C Operators
- Storage Classes In C
- C Pointers
- File Management
- C Identifiers
- Loop Control Statements
- Hello World - Simple C Program
- C Array
- Single Character Output Function : putchar()
- C Reserve Words
- C Specific Properties and Implementation
- If else Statement Example Program In C Programming Language
- If Statement Example Program In C Programming Language
- Confusing Array in C ( Array Representation and Initialization )