You are not logged in. Please login at www.codechef.com to post your questions!

×

regarding compilation error!!

#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??

asked 07 May '12, 00:04

geekspeak's gravatar image

0★geekspeak
111
accept rate: 0%

edited 09 May '12, 22:48

admin's gravatar image

0★admin ♦♦
17.4k347487515

i don't see any problem here. what is the printed message ?

(08 May '12, 00:35) cyberax ♦2★

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

link

answered 22 Aug '16, 19:20

rishabh.jain9196's gravatar image

5★rishabh.jain9196
31118
accept rate: 8%

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
link

answered 22 Aug '16, 21:55

yb4singh's gravatar image

5★yb4singh
1214
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; }

link

answered 23 Aug '16, 14:24

nagaraju474's gravatar image

0★nagaraju474
1
accept rate: 0%

On CodeChef your class cannot be public, use default: FiredOut and Kodi App. Thanks a lot for this.

link

answered 24 Dec '16, 13:47

larryplab's gravatar image

0★larryplab
11
accept rate: 0%

edited 12 Jul, 03:20

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.

link

answered 24 Dec '16, 17:35

pankaj_96's gravatar image

2★pankaj_96
1
accept rate: 0%

On CodeChef your class cannot be public, use default: Tango For PC. Thanks a lot for this.

link

answered 12 Aug, 15:18

justinpslab's gravatar image

0★justinpslab
1
accept rate: 0%

No condition on size of array mate

link

answered 13 Aug, 01:20

anmolmishra's gravatar image

3★anmolmishra
112
accept rate: 0%

toggle preview
Preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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,049 times

last updated: 13 Aug, 01:20