Write a C Program For A menu driven program using infinite loop and switch

Admin

 Write a C For A menu driven program using infinite loop and switch


#include<stdio.h>
int main(void)
{
    int choice;
    while(1)
    {
        printf("1.Create database\n");
        printf("2.Insert new record\n");
        printf("3.Modify a record\n");
        printf("4.Delete a record\n");
        printf("5.Display all records\n");
        printf("6.Exit\n");
        printf("Enter your choice : ");

        scanf("%d",&choice);
        switch(choice)
        {
            case 1:
                printf("Database created.....\n\n");
                break;
            case 2:
                printf("Record inserted.....\n\n");
                break;
            case 3:
                printf("Record modified.....\n\n");
                break;
            case 4:
                printf("Record deleted.....\n\n");
                break;
            case 5:
                printf("Records displayed.....\n\n");
                break;
            case 6:
                exit(1);
            default:
                printf("Wrong choice\n");
        }/*End of switch*/
    }/*End of while*/
    return 0;
}


Output


1.Create database
2.Insert new record
3.Modify a record
4.Delete a record
5.Display all records
6.Exit
Enter your choice : 1
Database created.....

1.Create database
2.Insert new record
3.Modify a record
4.Delete a record
5.Display all records
6.Exit
Enter your choice : 2
Record inserted.....

1.Create database
2.Insert new record
3.Modify a record
4.Delete a record
5.Display all records
6.Exit
Enter your choice : 3
Record modified.....

1.Create database
2.Insert new record
3.Modify a record
4.Delete a record
5.Display all records
6.Exit
Enter your choice : 4
Record deleted.....

1.Create database
2.Insert new record
3.Modify a record
4.Delete a record
5.Display all records
6.Exit
Enter your choice : 5
Records displayed.....

1.Create database
2.Insert new record
3.Modify a record
4.Delete a record
5.Display all records
6.Exit
Enter your choice : 6

Post a Comment

Cookie Consent
We serve cookies on this site to analyze traffic, remember your preferences, and optimize your experience.
Oops!
It seems there is something wrong with your internet connection. Please connect to the internet and start browsing again.
AdBlock Detected!
We have detected that you are using adblocking plugin in your browser.
The revenue we earn by the advertisements is used to manage this website, we request you to whitelist our website in your adblocking plugin.
Site is Blocked
Sorry! This site is not available in your country.