×

# regarding compilation error!!

 0 #include 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?? asked 07 May '12, 00:04 1●1●1 accept rate: 0% 0★admin ♦♦ 18.4k●347●492●528 i don't see any problem here. what is the printed message ? (08 May '12, 00:35)

 0 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 https://www.codechef.com/viewsolution/5157697 answered 22 Aug '16, 19:20 311●1●8 accept rate: 8%
 0 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 answered 22 Aug '16, 21:55 5★yb4singh 121●4 accept rate: 0%

# 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; }

1
accept rate: 0%

 0 On CodeChef your class cannot be public, use default: FiredOut and Kodi App. Thanks a lot for this. answered 24 Dec '16, 13:47 1●1 accept rate: 0%
 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. answered 24 Dec '16, 17:35 1 accept rate: 0%
 0 On CodeChef your class cannot be public, use default: Tango For PC. Thanks a lot for this. answered 12 Aug '17, 15:18 1 accept rate: 0%
 0 No condition on size of array mate answered 13 Aug '17, 01:20 13●2 accept rate: 0%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×5

question asked: 07 May '12, 00:04

question was seen: 1,123 times

last updated: 13 Aug '17, 01:20