If i want to print out five times something, in the same line | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

If i want to print out five times something, in the same line

i can use multiplication somehow, like 5* " " +"hello", or i have to type it out?

13th Nov 2016, 10:32 PM
Benedek Máté Tóth
Benedek Máté Tóth - avatar
4 Answers
+ 2
#include <iostream> using namespace std; int main() { for (int i = 0; i <=5; i++) { cout << "Hello" << endl; } return 0; }
13th Nov 2016, 10:57 PM
Kon
Kon - avatar
+ 1
Use a for loop For ( int i = 0; i <= 5; i++) { Your code goes here }
13th Nov 2016, 10:44 PM
Myleek Chase
Myleek Chase - avatar
+ 1
int i = 0; while( i < 5) { cout << "Hello World" << endl; i++; }
13th Nov 2016, 11:19 PM
Franky BrainBox
Franky BrainBox - avatar
0
thanks guys!
15th Nov 2016, 9:12 PM
Benedek Máté Tóth
Benedek Máté Tóth - avatar