+ 1

Write a prog. to continuously print the input no.s and stop printing when the input no. is 42 and exit when the input no. Is 101

the screen will be like: input: 1 2 3 98 42 45 101 output: 1 2 3 98

6th Jan 2018, 12:29 PM
Abdou Goda
Abdou Goda - avatar
6 Respostas
+ 4
code?
6th Jan 2018, 12:32 PM
Vukan
Vukan - avatar
+ 3
Python: done, exit=False, False while not exit: num = int(input("")) if num==42 : done = True if not done : print(num,"\n") if num==101 : exit = True
7th Jan 2018, 4:16 AM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
+ 2
Not sure if 101 is to be printed when encountered before a 42. But here is the code: C++: bool done=false, exit=false; int num; while(!exit) { cin>>num; if(num==42) done = true; if(!done) cout<<num<<endl; if(num==101) exit = true; }
6th Jan 2018, 12:40 PM
Solo Wanderer 4315
Solo Wanderer 4315 - avatar
0
in Python ? or any ?
6th Jan 2018, 5:09 PM
Nitesh Bhootra
Nitesh Bhootra - avatar
0
just python
6th Jan 2018, 10:58 PM
Abdou Goda
Abdou Goda - avatar
0
thanks
7th Jan 2018, 4:19 AM
Abdou Goda
Abdou Goda - avatar