Header Ads Widget

C program to input week number and print week day

 C program to input week number and print week day

Given a week number , write a program to print the week day i.e if week number is 1 then week day is Monday , if 2 then Tuesday and so on .

Sample input:

5

Sample output:

Friday

 C program to input week number and print week day

The objective of the code is print the week day based on the week number .

Code(C):-

#include<stdio.h>
int main()
{
int n;
printf("Enter week number\n");
scanf("%d",&n);
if(n==1)
printf("Monday");
else if(n==2)
printf("Tuesday");
else if(n==3)
printf("Wednesday");
else if(n==4)
printf("Thursday");
else if(n==5)
printf("Friday");
else if(n==6)
printf("Saturday");
else if(n==7)
printf("Sunday");
else
printf("Invalid input");
return 0;
}


Output:-

Enter week number
5
Friday

Recommended Post :-

HCL Coding Questions:-

Capgemini Coding Questions:-

Companies interview:-

Full C course:-    

Key points:-

Cracking the coding interview:-

 Array and string:-

Tree and graph:-

Hackerearth Problems:-

Hackerrank Problems:-

Data structure:-

 MCQs:-

Post a Comment

0 Comments