+ 1
I have a problem outputing (description) in C or C++ any one help?
Without using if only for loop... Output 1 6 2 7 3 8 4...
5 Antworten
+ 1
Daniel Kagombe
I am terrible in C, but I can offer a C++ solution which you may adapt to C.
#include <iostream>
using namespace std;
int main() {
for(int i=1; i<6; i++){
cout<<i<<endl;
cout<< i+5<< endl;
}
return 0;
}
+ 3
If you are struggling with this, then post your code attempt so we may assist further
+ 2
Daniel Kagombe
I am assuming you know how to construct a for loop, but don't understand how to create the pattern.
I would the following in C++.
Construct the for loop to repeat to your required number of iterations.
In the body of your loop
cout << iteration << endl << iteration +5 << endl;
+ 1
Thankyou it worked