C Program to Print Day of Week Name

C Program to Print Day of Week Name

C program to print day of week name; Through this tutorial, we will learn how to find and print day of week name using if else and switch case statement in c programs.

Programs to Print Day of Week Name in C

  • C Program to Print Day of Week Name using Switch Case
  • C Program to Print Day of Week Name using If Else

C Program to Print Day of Week Name using Switch Case

#include <stdio.h>

int main()
{
  int weekday;
  printf(" Please Enter the Day Number 1 to 7 (Consider 1= Monday, and 7 = Sunday) :  ");
  scanf("%d", &weekday);
  
  switch (weekday)
  {
  	case 1:
  		printf("\n Today is Monday");
		  break;
  	case 2:
  		printf("\n Today is Tuesday");
		  break;
  	case 3:
  		printf("\n Today is Wednesday"); 
		  break;
  	case 4:
  		printf("\n Today is Thursday"); 
		  break;
  	case 5:
  		printf("\n Today is Friday"); 
		  break;
  	case 6:
  		printf("\n Today is Saturday");
		  break;
  	case 7:
  		printf("\n Today is Sunday");
		  break;
	default:
		printf("\n Please enter Valid Number between 1 to 7");
  }
  return 0;
}

The output of the above c program; as follows:

 Please Enter the Day Number 1 to 7 (Consider 1= Monday, and 7 = Sunday) :  25

 Please enter Valid Number between 1 to 7

C Program to Print Day of Week Name using If Else

/* C Program to Print Day Name of Week using Else If Statement */

#include <stdio.h>

int main()
{
  int weekday;
  printf(" Please Enter the Day Number 1 to 7 (Consider 1= Monday, and 7 = Sunday) :  ");
  scanf("%d", &weekday);
  
  if (weekday == 1)
  {
  	printf("\n Today is Monday");  	
  }
  else if ( weekday == 2 )
  {
  	printf("\n Today is Tuesday");  	
  }  
  else if ( weekday == 3 )
  {
  	printf("\n Today is Wednesday");  	
  } 
  else if ( weekday == 4 )
  {
  	printf("\n Today is Thursday");  	
  } 
  else if ( weekday == 5 )
  {
  	printf("\n Today is Friday");  	
  } 
  else if ( weekday == 6 )
  {
  	printf("\n Today is Saturday");  	
  }   
  else if ( weekday == 7 )
  {
  	printf("\n Today is Sunday");  	
  } 
  else
    printf("\n Please enter Valid Number between 1 to 7");
  
  return 0;
}

The output of the above c program; as follows:

 Please Enter the Day Number 1 to 7 (Consider 1= Monday, and 7 = Sunday) :  5

 Today is Friday

Recommended C Programs

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of PHP, Python, Javascript, JQuery, Laravel, Livewire, Codeigniter, Node JS, Express JS, Vue JS, Angular JS, React Js, MySQL, MongoDB, REST APIs, Windows, Xampp, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL and Bootstrap from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published. Required fields are marked *