#include<stdio.h>
int main()
{
int array[5],i;
for(i=0;i<5;i++)
{
{
scanf("%d",&array[i]);
}
if(array[i]==42)
{
break;
}
else
printf("%d ",array[i]);
}
return 0;
}
what is the problem in its compilation??
#include<stdio.h>
int main()
{
int array[5],i;
for(i=0;i<5;i++)
{
{
scanf("%d",&array[i]);
}
if(array[i]==42)
{
break;
}
else
printf("%d ",array[i]);
}
return 0;
}
what is the problem in its compilation??
i don’t see any problem here. what is the printed message ?
There is no compilation error in this segment of the code.
I tried your solution to recheck, and got a WA. Here’s the link:
https://www.codechef.com/viewsolution/11231693
However, going by the code, looks like you are trying to solve “Life, the Universe, and Everything”. Therefore, there are a few things you must keep in mind. The numbers could be greater than 5 or 10. They could even be 10^6 or 10^7, so code accordingly.
If after sometime you are not able to figure out your mistakes, refer to my solution, here
You are declaring a array of 5 element , acc to question Life ,the Universe , there can be many numbers in input, There is no compilation error in your program . May be you are submitting your code with any other language ,submit it with c/c++ . But still your sol will get WA verdict Solution
#include<stdio.h>
int main()
{
int array[5],i;
for(i=0;i<5;i++)
{
{
scanf("%d",&array[i]);
}
if(array[i]==42)
{
break;
}
else
printf("%d ",array[i]);
}
return 0;
}
Are you taking some input out of the range of int.
If not than there should not be any any error.
I checked your code personally and it’s going fine.
No condition on size of array mate