What is The Purpose Of Switch Keyword in C- Programming??
Answers
Answered by
3
switch is used switch between different choices..
For eg :
printf("1 : ADD 2: SUB 3:DIVIDE 4: EXIT\n");
printf("Enter your choice\n");
scanf("%d",&choice)
switch(choice)
{
case 1:
// code for adding
case 2:
// code for subtracting
case 3:
// code for dividing
case 4:
// code to exit from this loop
}
This is a sample code.. Not full
For eg :
printf("1 : ADD 2: SUB 3:DIVIDE 4: EXIT\n");
printf("Enter your choice\n");
scanf("%d",&choice)
switch(choice)
{
case 1:
// code for adding
case 2:
// code for subtracting
case 3:
// code for dividing
case 4:
// code to exit from this loop
}
This is a sample code.. Not full
Answered by
0
Similar questions