Pages

Tuesday, March 25, 2025

code of switch operator to find out "7 days a week" with user input in C++

 #include <iostream>

using namespace std;
// switch operators
int main(){
    int day;
    cout << "enter a day: ";
    cin >> day;

    switch(day){
        case 1: cout << "Monday" << endl;
            break;
        case 2: cout << "Tuesday" << endl;
            break;
        case 3: cout << "Wednesday" << endl;
            break;
        case 4: cout << "Thursday" << endl;
            break;
        case 5: cout << "Friday" << endl;
            break;
        case 6: cout << "Saturday" << endl;
            break;
        case 7: cout << "Sunday" << endl;
            break;
        default : cout << "Invalid Day" << endl;
    }
    return 0;

}

No comments:

Post a Comment

3917. Count Indices With Opposite Parity (Brute Force) O(n2) + Optimized Solution O(n) + tips LEETCODE WEEKLY 500

  class Solution {     public int [] countOppositeParity ( int [] nums ) {          // approach 1 - checks every pair         int n = n...