Saturday, May 22, 2010

C++ help??

I am trying to figure out where I would input these numbers in the code so I can compile it.


#include %26lt;iostream%26gt;


using namespace std;





int main() {


int x;


while (cin %26gt;%26gt; x) {


for (int i=x; i%26gt;0; i--) {


cout %26lt;%26lt; '*';


}


cout %26lt;%26lt; endl;


}


return 0;


}


What would this program print with input 1 3 5 1 3 5?

C++ help??
What are you talking about? You can't plug the numbers into the code to see what it does. Pay attention to where the input is: in the while line.





The output is:


*


***


*****


*


***


*****





Can you see why? Look at the for loop and the way the blocks are nested. Indenting the code properly might help.
Reply:You may contact a C++ helper live at website like


http://gionram.com/
Reply:you can download a C++ compiler called Dev-C++ from bloodshed.net at http://www.bloodshed.net/dev/devcpp.html


If you ran this program and typed in 1 3 5 1 3 5 it would output





*


***


*****


*


***


*****





Hope this helps.


No comments:

Post a Comment