0% found this document useful (0 votes)
7 views

Menu C Program

C programming

Uploaded by

sohanrai096
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views

Menu C Program

C programming

Uploaded by

sohanrai096
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <stdio.

h>

int main()

int age, choice, number;

printf("Program Menu:\n");

printf("Press 1 to check age for voting.\n");

printf("Press 2 to print all even numbers from 1 to 100.\n");

printf("Press 3 to print all odd numbers from 1 to 100.\n");

printf("Press 4 to print a Multiplicaton Table.\n");

printf("Press 5 to exit.\n");

printf("\nEnter Your Choice:");

scanf("%d", &choice);

switch (choice)

case 1:

printf("Enter Your Age:");

scanf("%d", &age);

if (age >= 18)

printf("\nYou are allowed to vote!");

else

printf("\nYou are not allowed to vote!");

break;
case 2:

printf("Even Numbers from 1 to 100:\n");

for (int j=2; j<=100; j+=2)

printf("%d\t", j);

break;

case 3:

printf("Odd Numbers from 1 to 100:\n");

for (int i=1; i<=100; i+=2)

printf("%d\t", i);

break;

case 4:

printf("Enter a number to get its multiplication table:");

scanf("%d", &number);

printf("\nMultiplication Table:\n");

for (int i=0; i <=10; i++)

printf("%d x %d = %d\n", number,i,number*i);

break;

case 5:

printf("Exiting the Program Menu.");


break;

default:

printf("Wrong Input. Try Again.");

break;

printf("\n\nOut of the Switch.\n\n");

return 0;

You might also like