You are here:

C++/C++/MS-DOS question


Followup To
Question -
Hello, Im currently using a version of GNU C++ enclosed with my C++ for Dummies Book, and Im having problems running my programs...actually my "program" is a small conversion program, but the problem still exists.  When I try to run my program, Im returened to DOS, and my program runs, I enter the temp in Celsius, or I input whatever the program wants me to, but instead of revieving an output of the Farenheit temp, I recieve a msg saying, "Program Exit Code: 0 (0x000)"., and im returned to the RHIDE interface when I clik OK.  If I run another program or return to DOS, I can see in the history of my DOS window that it displayed the temp, it just didnt let me see it b/c I was taken back to the compiler.  i realize this has been a long question, but I hope you can help

Answer -
Normally I don't do this, but reply to this question and put in your source code and I'll take a look at it. it's probably something really simple, but without looking at the code, I can't determine whyh the error is happening.


heres the code, which came from the book, so I assumed there was no error in the code

//  Program to convert temperature from Celsius degree
//  units to Fahrenheit degree units:
//  Fahrenheit = Celsius  * (212 - 32)/100 + 32
#include <stdio.h>
#include <iostream.h>

int main(int nNumberofArgs, char* pszArgs[])
   // enter the temperature in Celsius
   int celsius;
   cout << "Enter the temperature in Celsius:";
   cin >> celsius;

   // calculate conversion factor for Celsius
   // to Fahrenheit
   int factor;
   factor = 212 - 32;

   //use conversion factor to convert Celsius
   // into Fahrenheit values
   int fahrenheit;
   fahrenheit = factor * celsius/100 + 32;

   // output the results
   cout << "Fahrenheit value is:";
   cout << fahrenheit;

   return 0;

This program does run fine. I think the problem might be with the way your compiler is working. The "Program Exit Code" box that pops up is just telling you that the program has ended. That's why the DOS box closes when you hit 'ok', but the info is still there when you look at the DOS history. I think that if you run the program from the DOS command line as oppose to running it from inside the compiler, it should run OK and the "Program Exit Code" box won't pop up. That's the only thing I can think of, given what you've told me. It must be the way the compiler works, which is a bit odd in my opinion (but I've seen stranger. Sorry I couldn't help more, but hopefully this will solve your problem.

Best Of Luck,


All Answers

Answers by Expert:

Ask Experts


Alan F.


Having problems with any basic or intermediate parts of C++? I can answer those questions for you using simple English. I have been taking C++ in school for a couple years, so I still remember what it was like to be a beginner (especially with C++, which is a difficult language)!


I have a C++ web page that discuses the basics of C++. The address is:

©2017 All rights reserved.