First, have you had any experience with functions? You know their format, how to call them, etc.?
Second, a general rule of thumb is that for any bracket "{", put that on the same indent as the code it is for (i.e., if you have an "if", after the parameters are set, on the new line, you want to line the "{" right under the "i" in if). Then, anything inside the bracket is a tab (usually 4 spaces in coding programs) further than the bracket. Like this:
Now, as for functions, if you are familiar with them, start simply with making one part of your program a function (probably start with the 1000's), then call that function in your "main()". You'll probably want to start with globals, just to make it easier, and then work on how to work with calling and returning variables through functions.Code:while(ans=='y' || ans=='Y') { cout<<"what number would you like to convert?:\n"; cin>>input; cin.ignore(); if(input>0 && input<4000 ) { roman=""; //thousands place to get remainder(1000-3000) i=1; n=input/1000; while(i<=n) { roman=roman+rome1000; i=i+1; }
And by the way, for your declaration of roman, for your output, you can avoid having to use the line (roman="") by simply declaring it in the while loop, or even in the if section it is used in. That will especially come in handy once you start passing variable through functions.



LinkBack URL
About LinkBacks



