Find a Day from week using switch case

Find a Day from week using switch case in C

#include<stdio.h>
#include<conio.h>
void main()
{
	int n;
	printf("Enter day number \n");
	scanf("%d",&n);
	switch(n)
	{
	case 1:
		{
		    printf("Monday");
		    break;
		}
	case 2:
		{
			printf("Tuesday");
			break;
		}
	case 3:
		{
			printf("Wednesday");
			break;
		}
	case 4:
		{
			printf("Thursday");
			break;
		}
	case 5:
		{
			printf("Friday");
			break;
		}
	case 6:
		{
			printf("Saturday");
			break;
		}
	case 7:
		{
			printf("Sunday");
			break;
		}
	default:
		{
			printf("Invalid day number");
		}
	}
	printf("\nHave a nice day");
	getch();
}

Output

Enter day number
1
Monday
Have a nice day

Find a Day from week using switch case in C++

#include<iostream>
#include<conio.h>
using namespace std;
void main()
{
	int n;
	cout<<"Enter day number \n";
	cin>>n;
	switch(n)
	{
	case 1:
		{
		    cout<<"Monday";
		    break;
		}
	case 2:
		{
			cout<<"Tuesday";
			break;
		}
	case 3:
		{
			cout<<"Wednesday";
			break;
		}
	case 4:
		{
			cout<<"Thursday";
			break;
		}
	case 5:
		{
			cout<<"Friday";
			break;
		}
	case 6:
		{
			cout<<"Saturday";
			break;
		}
	case 7:
		{
			cout<<"Sunday";
			break;
		}
	default:
		{
			cout<<"Invalid day number";
		}
	}
	cout<<"\nHave a nice day";
	getch();
}

Output

Enter day number
2
Tuesday
Have a nice day

Find a Day from week using switch case in C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Enter day number");
            int n = Convert.ToInt32(Console.ReadLine());
            switch (n)
            {
                case 1:
                    {
                        Console.WriteLine("Monday");
                        break;
                    }
                case 2:
                    {
                        Console.WriteLine("Tuesday");
                        break;
                    }
                case 3:
                    {
                        Console.WriteLine("Wednesday");
                        break;
                    }
                case 4:
                    {
                        Console.WriteLine("Thursday");
                        break;
                    }
                case 5:
                    {
                        Console.WriteLine("Friday");
                        break;
                    }
                case 6:
                    {
                        Console.WriteLine("Saturday");
                        break;
                    }
                case 7:
                    {
                        Console.WriteLine("Sunday");
                        break;
                    }
                
            }
            Console.WriteLine("Have a nice day");
            Console.ReadLine();
        }
    }
}

Output

Enter day number
4
Thursday
Have a nice day

Find a Day from week using switch case in java

import java.util.*;
class examples
{
public static void main(String[] args)
	{
	Scanner sc=new Scanner(System.in);
	System.out.println("Enter day number");
	int n=sc.nextInt();
	switch (n)
    {
        case 1:
            {
            	System.out.println("Monday");
                break;
            }
        case 2:
            {
            	System.out.println("Tuesday");
                break;
            }
        case 3:
            {
            	System.out.println("Wednesday");
                break;
            }
        case 4:
            {
            	System.out.println("Thursday");
                break;
            }
        case 5:
            {
            	System.out.println("Friday");
                break;
            }
        case 6:
            {
            	System.out.println("Saturday");
                break;
            }
        case 7:
            {
            	System.out.println("Sunday");
                break;
            }
        
    }
	System.out.println("Have a nice day");
	}
}

Output

Enter day number
7
Sunday
Have a nice day

Write a comment


Name Email Message