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

×

Is there any runtime error???

#include <iostream>
using namespace std;
int main()
{
    int t;
    cin>>t;
    int a;
    for(int i=0;i<t;++i)
    {
        cin>>a;
        a=a/2+1;
        cout<<a<<endl;
    }
    return 1;

}
it runs on other compilers but on chef compiler it just shows runtime error
and i dont find any
- divide by zero (not in my case)
- and memory limit exceds ( memory limit 5000 bytes)

asked 04 Oct '17, 23:32

parasbhanwal's gravatar image

2★parasbhanwal
1
accept rate: 0%

edited 04 Oct '17, 23:34

vijju123's gravatar image

5★vijju123 ♦♦
15.5k12066


It is because of return 1;

You should do : return 0;

It is because non-zero value signify abnormal termination .

Link for some reference : https://stackoverflow.com/questions/204476/what-should-main-return-in-c-and-c

link

answered 04 Oct '17, 23:37

trashmaster's gravatar image

2★trashmaster
98619
accept rate: 12%

edited 04 Oct '17, 23:40

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:

×100

question asked: 04 Oct '17, 23:32

question was seen: 207 times

last updated: 04 Oct '17, 23:40