Lecture-4 [Conditional Statements]

1. if-else-if.cpp


#include <iostream>
using namespace std;

int main()
{
    int age = 18;
    printf("What is you age\n ");
    cin >> age;

    if (age < 18)
    {
        printf("gar par ja kar so ja ");
    }
    else
    {
        printf("welcome bro yoyo");
    }

    return 0;
}



2. if-else-if.cpp


#include <iostream>

using namespace std;

int main ()
{
    int age=10;
    printf("Bosdi vala chacha umar bta ?\n");
   
    cin>>age;
    if (age<18)
    {
        printf("Ja ka dud pi nu BC");
    }
    else if (age>18)
    {
        printf("enjoy tau...");
    }
    else
    {
        printf("tara bs bi na ha khuvarss lutna");
    }
   
    return 0;


}





3.  Switch.cpp


#include <iostream>
using namespace std;
int main()
{
    int age = 80;
    printf("choose a Number\n");
    printf("A. 10\n");
    printf("B. 20\n");
    printf("C. 30\n");
    printf("D. Nothing\n");

    cin >> age;

    switch (age)
    {
    case 10:
        cout << "Wronge age";
        break;
    case 20:
        cout << "Right age";
        break;
    case 30:
        cout << "Wrong age";
        break;
    default:
        cout << "Thank you BC";
    }
    return 0;
}






My Test


1. Option.cpp



#include <iostream>
using namespace std;

int main()
{

    char c, a, b, d;
    printf("Whos is PM of India ?\n");
    printf("A. Rajiv Modi\n"
           "B. Vikash SIngh\n"
           "C. Narandra Modi\n"
           "D. Tara Chacha\n");
    cin >> c;

    if (c = a)
    {
        printf("you answare is Wrong\n");
    }

    if (c = b)
    {
        printf("Answare Worng\n");
    }

    if (c = c)
    {
        printf("Your answare is Right\n");
    }

    if (c = d)
    {
        printf("chala ja bosdi ka\n");
    }

    return 0;
}




2.  Switch.cpp


#include <iostream>

using namespace std;

int main()
{
    int ans = 10;
    printf("\n \n \n \n \n \n ");
    printf("Choose one Right Number\n");
    printf(" 1. Ajay Singh Shekhawat\n 2. Vikash Singh Shekhawat\n 3. Ishu Singh Shekhawat\n 4. All");

    printf("\n \n");

    printf("Enter you nummber\n \n");

    cin >> ans;

    switch (ans)
    {
    case 1:
        printf("Oh Your Answare is Right");
        break;

    case 2:
        printf("Sorry Your Name is Wronge");
        break;

    case 3:
        printf("Sorry Your Name is Wronge");
        break;

    case 4:
        printf("Sorry Your Name is Wronge");
        break;

    default:
        break;
    }
    return 0;
}

Give Same Suggestion