×

Why this code gives runtime error

 0 #include < stdio.h > void main() { int i = 0; int T; int N; printf("Enter the 'T' value : "); scanf("%d",&T); for(i = 0;i 1) { printf("count = %d\n",(count+2)); } else if(number == 1) { printf("count = 1\n"); } else { printf("count = 0\n"); } } }  asked 08 Jul '13, 19:11 1●1●3 accept rate: 0% 4.2k●5●23●64 1 not able to indent. Please use code tag and upload again with proper indentation :) (08 Jul '13, 19:23)

 0 Please give the ideone link!!That would be easier to read!!Or while posting code indent it!! answered 08 Jul '13, 20:25 425●3●7●17 accept rate: 4%
 0 U are using void main it causes issues. Use int main with return 0 in the end. Also dont prompt user for input, U will get a wrong ans error if u do so. answered 08 Jul '13, 22:33 4★abbas 411●8 accept rate: 28%
 -1 You are getting a runtime error because, the very first line of your code is wrong. When you are using #include, you are expected to give the name (or path) of a header file within the angle brackets -- no space, no extra characters. Change it to #include  or #include (see, no spaces between < and >). Now, you might again get a runtime error (probably and more specifically, an NZEC - Non-Zero-Exit-Code - error) because, you main does not return 0. A successfully completed C/C++ program is expected to return 0 (EXIT_SUCCESS) from the main (or from wherever the program terminates). Try changing your void main() to int main(). Also, a few words of caution: you might still not get an accepted solution, if the output your code produces is not STRICTLY as per what the problem asks you to print. So, if the program does not ask you to output "Enter the 'N' value", then you shall not output the same. The program will be judged wrong answer for that. answered 08 Jul '13, 22:51 4.2k●5●23●64 accept rate: 15%
 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:

×21

question asked: 08 Jul '13, 19:11

question was seen: 751 times

last updated: 08 Jul '13, 22:51