0

How can I make program where you input a word where it outputs and repeats for as many times as it has letter in the word?

I only know the basic of the while function and of function so I have no idea how to. example : input = hello output = hello = hello = hello = hello

14th Jan 2017, 3:16 PM
Maverick Ballos
Maverick Ballos - avatar
6 Réponses
+ 5
You want someone to code it for you or you just want the idea?
14th Jan 2017, 3:31 PM
Karl T.
Karl T. - avatar
+ 5
int i=0; while(i< word.length()) { cout<<word; i++; }
14th Jan 2017, 3:38 PM
Karl T.
Karl T. - avatar
+ 4
Use length() on the word string and loop using a for loop with the length as end condition.
14th Jan 2017, 3:22 PM
Karl T.
Karl T. - avatar
+ 4
#include <string> in your program to use it.
14th Jan 2017, 3:34 PM
Karl T.
Karl T. - avatar
0
just wanted some idea using only while and of funtion so dont know how to use length() yet.
14th Jan 2017, 3:32 PM
Maverick Ballos
Maverick Ballos - avatar
0
here's idea 1 use string header 2 a is string variable which holds ur input 3 strlen(a) to get length of input string 4 use while(length > 0) and print string with length- - 5 done 6 like this answer
14th Jan 2017, 3:39 PM
Dipak Chauhan
Dipak Chauhan - avatar