嵌套开关案例程序中的编译错误

时间:2017-06-12 01:30:00

标签: loops compilation nested switch-statement case

#include<stdio.h>
#include<conio.h>
include<stdlib.h>
main()
{
int choice, flag;
while(1)
{
    system("cls");
    printf("\t\tMain Menu\n");
    printf("1- Students Record\n");
    printf("2- Teachers Record\n");
    printf("3- Exit\n");
    printf("Enter your choice\n");
    scanf("%d",&choice);
    switch(choice)
    {
        case 1:
            flag=1; // Assign valu 1 to flag, rather equality sign. Because at this point flag is not equal to 1
            while(flag==1)
            {
                system("cls");
                printf("Student Record System\n");
                printf("1- Add Record\n");
                printf("2- Display Record\n");
                printf("3- Edit Record\n");
                printf("4- Go back to main menu\n");
                printf("Enter your choice\n");
                scanf("%d", &choice);
                swich(choice)
                {
                    case 1:
                        printf("Add Record\n");
                        system("pause");
                        break;
                    case 2:
                        printf("Display Record\n");
                        system("pause");
                        break;
                    case 3:
                        printf("Edit Record\n");
                        system("pause");
                        break;
                    case 4:
                        flag==0
                    default
                        printf("Enter correct choice\n");   
                }
            }
        case 2:
                flag=1; 
            while(flag==1)
            {
                system("cls");
                printf("Teacher Record System\n");
                printf("1- Add Record\n");
                printf("2- Display Record\n");
                printf("3- Edit Record\n");
                printf("4- Go back to main menu\n");
                printf("Enter your choice\n");
                scanf("%d", &choice);
                swich(choice)
                    {
                        case 1:
                            printf("Add Record\n");
                            system("pause");
                            break;
                        case 2:
                            printf("Display Record\n");
                            system("pause");
                            break;
                        case 3:
                            printf("Edit Record\n");
                            system("pause");
                            break;
                        case 4:
                            flag==0
                        default
                            printf("Enter correct choice\n");   
                    }
            }


        case 3:
            exit(0);
        default:
            printf("Enter correct choice\n");

    }
}

Compilation Errors}

请指导我如何解决此嵌套切换案例程序中的问题。当我尝试编译代码时。我得到了错误。 我一次又一次地检查,但我无法看到问题存在的地方。 所以请帮助我。

0 个答案:

没有答案