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 | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 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 Answers
+ 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
Kinshuk Vasisht
Kinshuk Vasisht - 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
Kinshuk Vasisht
Kinshuk Vasisht - 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