- 1

How to print numbers horizontal using for loop

In C: #include <stdio.h> int main() { for (int i = 0; i < 10; i++) { printf("%d ", i); } return 0; } --- In C++: #include <iostream> using namespace std; int main() { for (int i = 0; i < 10; i++) { cout << i << " " << flush; } return 0; } --- In Python: for i in range(0, 10): print(i, " ", end="") https://www.sololearn.com/discuss/1779454/?ref=app

1st May 2019, 3:01 PM
MICHAEL Gicheri
4 Answers
+ 3
The code written in the Description seems very similar with an answer on the following thread, just a few hours back. MICHAEL Gicheri Did you go to same school with that thread owner? you both ask this very same question, same homework? https://www.sololearn.com/Discuss/1781916/?ref=app Try search before you post next time, it will help reduce duplicate questions ...
1st May 2019, 3:43 PM
Ipang
+ 2
You can see it in my example. Hope it helps you. https://code.sololearn.com/cN2l8dI4Sgm1/?ref=app
1st May 2019, 3:11 PM
TheWh¡teCat 🇧🇬
TheWh¡teCat 🇧🇬 - avatar
+ 1
got it
1st May 2019, 3:09 PM
MICHAEL Gicheri