Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

please tell me some programmes using if and switch

+1 vote
asked Sep 16, 2018 by Sahil123 (130 points)

3 Answers

0 votes
answered Sep 18, 2018 by Shane Such (860 points)
any interactive programme with multiple choices Duh
0 votes
answered Sep 18, 2018 by Cartoon World (140 points)
#include<stdio.h>
main()
{
    int choice;
    float temp,convertedTemp;
    printf("Press the button to convert:");
    printf("Press 1: For calculate celcious to farhenhite");
    printf("Press 2: For calculate fahrenhite to celcious");
    scanf("%d",&choice);

    switch(choice)
    case 1:
    {
    printf("Enter the temp:");
    scanf("%f",&temp);
    convertedTemp=(temp-32)/(1.8);
    printf("%f",convertedTemp);
    }
case 2:
    {
        printf("Enter the temp:");
        scanf("%f",&temp);
        convertedTemp=(temp*1.8)+32;
        printf("%f",convertedTemp);
    }
default
        printf("Invalued Keyword");

}
0 votes
answered Sep 21, 2018 by anonymous

int main()

{

    bool condition1;

    bool condition2;

    if (condition1)

    {

        // The program does this if condition1 is true.

    }

    else if (condition2)

    {

        // The program does this if condition1 is false and condition2 is true.

    }

    else

    {

        // The program does this if neither condition1 nor condition2 is true.

    }

   

    int case;

    switch (case)

    {

    case 0:

        // The program does this if case is equal to 0;

        break; // This breaks out of the statement.

               // If this wasn't here, it would continue through all the remaining cases.

    case 1:

        // The program does this if case is equal to 1;

        break;

    case 2:

        // The program does this if case is equal to 2;

        break;

    default:

        // The program does this if case is equal to none of the cases;

    }

    return 0;

}

Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...