Code for the practice Problem Life, the Universe, and Everything'.Its giving the wrong Answer._Please anyone Analyse and tell???

#include
using namespace std;
int main()
{
int a;
A:
cin>>a;
if(a==42) return 0;
cout<<a;
goto A;
return 0;
}

1 Like

for input

1
2
3
42

it prints

123
1 Like

try adding a new line character after printing each time… cout<<a<<endl; instead of cout<<a; …hope this helps…:slight_smile:

1 Like