Problem 14

author
By Supreme2023-02-23
Problem Statement :
Write a C program to read no 1 to 7 and print relatively day Sunday to Saturday
Code:

#include <stdio.h>

int main()
{

// 14. Write a C program to read no 1 to 7 and print relatively day Sunday to Saturday

int day;

printf("\tDay Presentation");
printf("\n===================================");

printf("\n\nEnter The Number For Day (1-7): ");
scanf("%d", &day);

printf("\n__________________________________\n\n");

switch (day)
{
case 1:
printf("%d Represent Sunday",day);
break;

case 2:
printf("%d Represent Monday",day);
break;

case 3:
printf("%d Represent Tuesday",day);
break;

case 4:
printf("%d Represent Wednesday",day);
break;

case 5:
printf("%d Represent Thursday",day);
break;

case 6:
printf("%d Represent Friday",day);
break;

case 7:
printf("%d Represent Saturday",day);
break;
}

printf("\n__________________________________\n\n");
return 0;
}

Description :
  • This program reads an integer input from the user representing a number from 1 to 7 which corresponds to a day of the week (Sunday to Saturday) and then prints out the corresponding day name using a switch statement. If the user enters an integer outside the range of 1 to 7, the program does not output anything.
Output Image:
Output-image

© Copyright 2022. All right reserved, GTU Coder.