lundi 8 novembre 2021

can i use switch case instead of if and else statement or is there any other way to do the same using different method in c

#include <stdio.h>
int main()
{

    int mark;

    printf("eenter your marks :");
    scanf("%d", &mark);

    if (mark < 40)
    {
        printf("your markade is f ");
    }
    else
    {
        printf(" you havve paassed the subject\n");

        if (mark > 40)
        {
            printf("enter the marks again again: ");
            scanf("%d", &mark);
            if (mark < 50)

            {
                printf("your grade is e");
            }

            else

            {
                printf("you have a higher grade enter marks again ");
                scanf("%d", &mark);
                if (mark < 60)
                {
                    printf("your grade is d ");
                }
                else
                {
                    printf("you have hif=gher grade enter marks again :");
                    scanf("%d", &mark);
                    if (mark < 70)
                    {
                        printf("your grade is c");
                    }
                    else
                    {
                        printf("your grade is higher enter marks again ");
                        scanf("%d", &mark);
                        if (mark < 80)
                        {
                            printf("your grade is b ");
                        }
                        else
                        {
                            printf("your grade is higher enter marks again ");
                            scanf("%d", &mark);
                            if (mark < 90)
                            {
                                printf("your grade is a");
                            }
                            else
                            {
                                printf("your grade is a+ ");
                            }
                        }
                    }
                }
            }
        }
    }

    return 0;
}

this is if else statement code please tell me how can i do the same with different approach this is if else statement code please tell me how can i do the same with different approach this is if else statement code please tell me how can i do the same with different approach this is if else statement code please tell me how can i do the same with different approach this is if else statement code please tell me how can i do the same with different approach this is if else statement code please tell me how can i do the same with different approach this is if else statement code please tell me how can i do the same with different approach this is if else statement code please tell me how can i do the same with different approach this is if else statement code please tell me how can i do the same with different approach

Aucun commentaire:

Enregistrer un commentaire