+ 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
6 Answers
+ 4
code?
+ 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
+ 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;
}
0
in Python ?
or any ?
0
just python
0
thanks