41 / 41
Apr 2021

Thanks for your help.. But,I think that they should be more worried about logic instead of the source of input...Anyways I will take care of all the things that you have told me and try to solve some good problems.

How come the judge understand your logic until you process the given input and print the desired output..

I don't understand what actually you are trying to do.

anyway..good luck. smiley

What is the input constraint for this problem???I am getting a run time error..
question question question

If you are looking for a maximum on the number of integers in the input, there is none. There could be 5, there could be one billion.

2 years later

Hi everyone, i don't understand what is wrong in my code... if someone can help me...

#include <stdio.h>

int main(){
    int num;
    do {
        scanf("%d", &num);
        printf("%d", num);
    } while(num != 42);

    return 0;
}
  1. You have to print each number on a separate line
  2. The number 42 must not appear in the output
1 month later

Hey guys,
I am particularly new to coding I tried with C while giving a solution to this problem but I'm always getting an SIGSEGV error
Pleas Help!!
Here is my code

#include <stdio.h>

int main() {
	int a[20], x, count=0;
	do{
		scanf("%d\n", &x);
		a[count]=x;
		count++;
	}while(x!=42);
	
	x=0;
	for(x; x<count-1; x++){
		printf("%d\n", a[x]);
	}
	return 0;
}
9 months later

#include <stdio.h>

int main(void) {
// your code here
int a;
while(a!=42)
{
scanf("%d",&a);
if(a==42)
break;
printf("%d",a);
}

return 0;

}
Can u find problem in this code ?

is there any problem with this code.??it gives the output but still its showing error.

#include<stdio.h>
int main()
{
int i,n,j;
int ch[5];
scanf("%d",&n);
for(j=0;j<n;j++)
{
scanf("%d",&ch[j]);
}
for(i=0;i<n;i++)
{
if(ch[i]<ch[i+1])
printf("\n%d",ch[i]);
else
break;
}
if(ch[i]>ch[i+1])
printf("\n%d",ch[i]);
return 0;
}

8 months later

I Have corrected your problem in my code.

here you go.

#include <stdio.h>

int main(void)
{
// your code here

int n;
while(scanf("%d", &n)&&n<=99)
{
    if (n==42)

    break;

    else

    printf("%d\n", n);


}


return 0;

}

10 months later

#include

using namespace std;

int main(){

int batas;
cin >> batas;
int input[batas]; 
for(int i=0; i<batas; i++){
	cin >> input[i];
}

for(int i=0; i<batas; i++){
	if(input[i]==42){
		exit(0);
	} else {
		cout << input[i] << endl;
	}
}


cin.get();
return 0;

}

what’s the problem?

1 month later

hey guys! tried to submit my first problem but failed wonder what’s wrong with this one, any help?
int i,size=1,ar[100],ans;
for(i=1;ans!=42;)
{

	if(ans==42)
	break;
	cin>>ans;
	ar[i]=ans;
	size++;
	i++;
}
for(i=1;i<size;i++)
cout<<ar[i]<<"\n";
2 months later

here is the simple solution in c++…

#include
using namespace std;

int main(){
int x ;

while( x !=42){
 cin >> x;
if(x !=42){
        cout << x << endl;
}
}

}

Hello atifasr,

A few remarks about your code:
What do you think happens to your program if the input contains more than 100 numbers ?
Your variables size and i are effectively the same thing. They’re both initialized to 1, and incremented at the same time.
The variable ans is used uninitialized on the first iteration of the loop.
You’re checking if ans == 42 at the start of a loop that will be entered only if ans != 42. That condition in your if can never be true.
You are THEN storing the input into ans, and not checking if it is now == 42. When 42 is encountered, it is going to be put in your array, supposing less than 100 numbers have been read so far.

I suggest you think about what you want to do exactly and what the constraints are, sort everything out so that it makes sense, and then start typing code.

5 months later

what is the problem in my code-:

#include<stdio.h>
#include<stdlib.h>

int main(){

int input, outputr[10],i=0,j=0;
while(i<=5){

scanf("%d",&input);

outputr[i]=input;
i++;
}
while(j<i){
if(outputr[j]==42)
{break;}
else{
printf("%d\n",outputr[j]);}
j++;
}
return 0;

}

3 months later
1 year later

Hello can anyone tell me what is wrong with this python 3 code of mine
active = True
while active:
n = int(input('Enter the number= '))
if n == 42:
active = False
else:
print(n)
I am unable to find any error in this code of mine but it still shows wrong answer on SPOJ