### i need help

 ``123456789101112131415161718192021222324252627282930313233343536373839`` ``````#include using namespace std; int main() { int i; int num; cout <<"Give a value of n: " << endl; cin >> num; while(num>0) { for(i=0; i+1; i++) cout << "o"; } { for(i=0; i+0; i++) cout << "^"; } cout << "Enter a value" ; cin >> num; cout << endl; system ("pause"); return 0; }``````

Hello i need help for this problem i donâ€™t know what is wrong i tried to solve them and it doesn't come out the solution !

The program should ask the user to enter the value of n, and then print out what is shown
above. The program should repeat this procedure as long the user enters non-negative values.

If n is 4
ooooO
^^^^
If n is 10
ooooooooooO
^^^^^^^^^^
Last edited on
`for(i=0; i+1; i++)`
What are you trying to do with this?
I didn't get the chance to test this, just wrote it based on your example.
Check if it works

 ``12345678910111213141516171819202122232425262728`` ``````#include using namespace std; int main() { int num; int temp; cout<<"Enter a positive value\n"; cin>> num; temp=num; for(int i=1; i<(num+1); i++) { cout<<"o"; } cout<
nic, your while loop will never end. Nothing in that loop changes the value of `num`. If it is greater than 0, then it will enter the loop and will loop infinitely, as it will stay greater than 0 for ever.

For that matter, your for loop will never be entered. You've put `i+0` as your loop check condition. Since you initialise i to 0, the first time this is checked, i+0 will be 0 + 0 = 0, i.e. false. The loop will therefore immediately exit.

What are you trying to achieve with your while loop?

What are you trying to achieve with your for loop?
Topic archived. No new replies allowed.