![]() |
combining
how can i combine this 2 c++ in to 1 c++ prog thx for the help
the first one Code:
#include <iostream>Code:
#include <iostream> |
Re: combining
Put them into separate function and use the user to select which one to be executed.
|
Re: combining
@shizzle08 :
Why do both your programs end with "return main();" ? That will let your program fall into an infinite loop and you have to manually break your program's execution. If you wanted to repeat the portion inside main(), then you can use some other techniques like while(<some condition>) or for(<something else>) etc... and always return 0; |
Re: combining
i dont have any idea what your telling can u please edit my prog..? i newbie
|
Re: combining
(1) Put both main() functions into a new file.
(2) Rename both main() functions to something appropriate. (3) Write a new main() function to call the two functions in whatever order you see fit. Saswat is talking about this line of code: Code:
return main();Code:
return;Code:
int func() // returns an integerCode:
void func() |
Re: combining
this is how it should be sir...
Quote:
Quote:
Quote:
|
Re: combining
sorry for double posting i can't see the edit button
@sir xpi0t0s can u make me a c++ that has basic calculator,number of days. so that i cant see how to do it thanks |
Re: combining
No, the idea of you being given assignments is that you learn by figuring this stuff out for yourself, using the course notes you've already been given. All you need to solve this is some input, output and some if statements, all of which you already know from the code you've already written. So start by displaying the menu selections, reading an option from the user and displaying it back to them. Make sure that works, then start adding code to process that input; if it equals 1 then call a function that reads the values from the user, processes them and prints some output. Make sure that works OK, then add more code to handle the other options.
|
Re: combining
Finish.:)) one last thing after they use one of the following a question will prompt asking if they want to use it again? 'Y' or 'N' and if 'Y' then it will return to Int Main () if 'N' it will close? hehe
PHP Code:
|
Re: combining
Not sure if that's a question; if it is, just wrap the contents of main in a for(;;) block and add a menu option, e.g. 8 Quit, and make case 8 return 0; Then the program will quit when they select 8; this is better than having a separate Y/N prompt to continue or quit. Think about the design, if you have several tasks to perform with the program, you would want to run them one after the other then select quit when you're done; you don't want to be asked whether or not to continue after every operation.
|
| All times are GMT +5.5. The time now is 06:55. |