Skip to content

Instantly share code, notes, and snippets.

@VishalVishwakarma
Created March 2, 2017 07:32
Show Gist options
  • Save VishalVishwakarma/beceb671fe5f42ed66a57b9a37b2eb5b to your computer and use it in GitHub Desktop.
Save VishalVishwakarma/beceb671fe5f42ed66a57b9a37b2eb5b to your computer and use it in GitHub Desktop.
While-Switch function continuous loop demo in C language
#include <stdio.h>
#include <conio.h>
int main(){
int answer = 1;
int choice;
while (answer == 1){
printf("\n\n*****CHOOSE YOUR CHOICE*****\n");
printf("1) ADD DATA\n");
printf("2) DELETE DATA\n");
printf("3) SHOW ALL\n");
printf("4) SHOW RECORD\n");
printf("5) ALTER DATA\n");
printf("6) Exit \n");
printf("Enter your choice : ");
scanf("%d", &choice);
switch(choice){
case 1 : printf("1");
break;
case 2 : printf("2");
break;
case 3 : printf("3");
break;
case 4 : printf("4");
break;
case 5 : printf("5");
break;
case 6 : printf("6");
break;
default: printf("error");
}
printf("\nDo you want to continue (1/0): \n");
scanf(" %D", &answer);
}
printf("GoodBye!");
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment