im writing a program that includes a menu,and has 2 options.i can write the program but when i enter and option,and complete it,how can i get the program to go back to the main menu??
im writing a program that includes a menu,and has 2 options.i can write the program but when i enter and option,and complete it,how can i get the program to go back to the main menu??
Put the codeon line 47 of your second function.Code:return2menu();
OR. . .
Post your code so we can help you.
Pick better topic titles as well.
If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
If at first you don't succeed, try writing your phone number on the exam paper.
sorry,this is my code:
Code:#include <stdio.h> main() { int option ; printf( "Welcome to the main menu,please chose from the following options...:\n\n" ) ;//menu greating printf( "1. opt1.\n\n" ) ;//option 1 printf( "2. op2.\n\n" ) ;//option 2 printf( "Please chose an option between 1 - 2:\n") ; scanf( "%d",&option) ;//option input switch (option) //begining of switch statement { case 1: printf( "this is opt1\n") ; // begining of option 1 case 2: printf( "this is opt2" ) ; break ; }//end switch }//end main
Ever heard of a while loop??
In the middle of difficulty, lies opportunity
yeh,but i cant really do them,im learningOriginally Posted by kris.c
we appreciate the fact that you atleast tried
You can think of this :
Code:#include <stdio.h> int main() { int option ,flag=0; printf( "Welcome to the main menu,please chose from the following options...:\n\n" ) ;//menu greating printf( "1. opt1.\n\n" ) ;//option 1 printf( "2. op2.\n\n" ) ;//option 2 printf(" 3. exit \n\n"); while(flag == 0) { printf( "Please chose an option between 1 - 2:\n") ; scanf( "%d",&option) ;//option input switch (option) //begining of switch statement { case 1: printf( "this is opt1\n") ; // begining of option 1 case 2: printf( "this is opt2" ) ; break ; case 3: printf(" exit"); flag=1; break; }//end switch } // end while return 0; }//end main
In the middle of difficulty, lies opportunity
thank you good sir!
wow! thats the best response I have ever got .
and hey,I am just 20, so, dont bother about calling me that
In the middle of difficulty, lies opportunity
didnt work!!well it did,but its saying i display opt2 also!!
no sweat.. you have forgotten to insert a "break" statement after the "case 1."
In the middle of difficulty, lies opportunity
ah yes,thanks man