How to print something as many as the input given

in this program i want to give input like this

5 2 4

and i want that hello world should be printed first 5 times and after that 2 times and after that 4 times.
how to make this possible?
how to take multiple inputs?

hi @Anku47
if you know that you want 3 inputs, you can run the loop 3 times.
Or you could first ask the user how many times they want to take input, lets say n. So run a loop n times, and then take input inside each loop, as to how many times you want to print hello world.
See this https://ide.codingblocks.com/s/284046 for reference

but ma’am what if i want input like 5(space)4(space)3 in the very first and in a single line and then after pressing enter i want to cout<< hello world 5 time 4time 3 time…

@Anku47 then you will have to read the input till EOF, end of file.

ma’am can you please explain while(!cin.eof()) in detail?

@Anku47 cin.eof() checks for end of file, it returns TRUE when end of file is reached. So the condition
!cin.eof() becomes false when EOF is reached (!true means false) and the loop breaks. we are taking input via cin stream, hence cin.eof() is used. There are other syntax for this too so dont get confused if you see some other syntax for this, they all do the same thing.

https://ide.codingblocks.com/s/284048 what if i have to set constraints in this that n<=20 and the second input <=100. how to set the limit to n ???

@Anku47 you never manually set constraints. Constraints means that the input will never exceed that.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.