Click here to Skip to main content
15,998,100 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I have typed a program to calculate SI in C using dos box and Turbo C compiler.
My program gets compiled but it doesn't show the output.

What I have tried:

I have also typed a program to show 'hello world'. it shows the output perfectly. but when i try to execute the SI program , the output opens and closes in a blink, without showing the output.
Posted
Updated 9-Oct-16 4:20am
Comments
[no name] 9-Oct-16 10:09am    
I will let you in on a little secret. Computers are stupid. They only do what you tell them to. The most likely explanation for your program behaving in the manner that you describe, is that is exactly what you told it to do. Unfortunately, we can't see either one of your programs from halfway around the world so we can't tell you what you did.

1 solution

The problem is that when you run a console app, it expects input from the user - and if it doesn't get it, it doesn't wait around - it closes and the console window is closed as well. As a result, you can't see anything on the screen because it just isn't there for long enough.
All you have to do is "force" it to wait for you before closing:
C++
void main()
   {
   printf("Hello World!\n");
   getchar();
   }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900