Hi I have to make a menu for a general case using just if else statement and do-while , while and for loops .
Also for the choice 1 and choice 2 after printing it should show the main menu again only for choice 3 it should exit the program .
Thanks for your help
Code:
#include <stdlib.h>
#include <stdio.h>
int main()
{
int choice=0;
do{
printf("Please select one of the choice\n\n");
printf(" 1) Calcultae resistance value\n");
printf(" 2) Help\n");
printf(" 3) Exit\n");
scanf("%d",&choice);
if (choice<1 || choice>3)
{
printf("Invalid choice\n");
printf("Select again\n\n");
choice=0;
}
}
while(choice<1 || choice>3);
do {
if (choice==1)
{
printf("The value is\n");
choice=0;
}
else if (choice==2)
{
printf("The help menu \n");
choice=0;
}
}
while (choice!=3 );
system("exit");
return 0;
}