Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

C program code to print personal details using switch

Can write a code to show personal details using switch in c language
by

1 Answer

sam5epi0l
Yes. it can be used like this:


#include <stdio.h>

int main() {
int option;
printf("Enter your choice:\n");
printf("1. Name\n");
printf("2. Age\n");
scanf("%d", &option);

switch(option) {
case 1:
printf("My name is Jack Doe.\n");
break;
case 2:
printf("I am 20 years old.\n");
break;
default:
printf("Invalid option.\n");
}

return 0;
}

Login / Signup to Answer the Question.