| GIjessiebear (28) | |
|
//Chapter 5 Review 4 //Aurora Van De Water #include <iostream> using namespace std; void SpanishNum(); void SpanishNum(int num) { while (num==1){ cout << num << "uno"<<endl; } while(num==2){ cout << num << "dos"<<endl; } while(num==3){ cout << num << "tres"<<endl; } while(num==4){ cout << num << "quatro"<<endl; } while(num==5){ cout << num << "cinco"<<endl; } } int main(){ int num=0; for(int num = 0; num <= 5; num++) SpanishNum(num); return(0); } | |
|
|
|
| AbstractionAnon (414) | |
| Is there a question here? | |
|
|
|
| martianxx (33) | |||
the problem you have is that as soon as you pass num = 1 to that function num is never changed again and so you get stuck in an infinite loop. Instead of using while loops use a switch statement like so:
| |||
|
|
|||
| Darkmaster (341) | |
| use if instead of while | |
|
|
|