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

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including 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. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

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