9d0 Subj : C++ functionality To : borland.public.cpp.borlandcpp From : ron Hopkins Date : Wed May 25 2005 09:41 am I am a high school Business Education teacher, and my lab is equipped with C++ 5.02. I teach an introductory programming course with segments on Visual Basic, HTML_JavaScript, JAVA and C++. My C++ is problematic in its operation, in that it will only run portions of programs. (1)For example, the following code is from a text that I'm using: // Travel Efficiency // // Purpose: Calculates miles per gallon and price per mile when // given miles traveled, number of gallons used, and gas price. #include // necessary for cin and cout commands int main() { // Variable declarations float MilesTraveled; // stores number of miles float GallonsUsed; // stores number of total gallons used float PricePerGallon; // stores price per gallon float PricePerMile; // stores price per mile float MilesPerGallon; // stores number of miles per gallon // Ask user for input values. cout << "How many miles did you travel? "; cin >> MilesTraveled; cout << "How many gallons of gas did you use? "; cin >> GallonsUsed; cout << "How much did one gallon of gas cost? $"; cin >> PricePerGallon; // Divide the number of miles by the number of gallons to get MPG. MilesPerGallon = MilesTraveled / GallonsUsed; // Divide price per gallon by miles per gallon // to get price per mile. PricePerMile = PricePerGallon / MilesPerGallon; // Output miles per gallon and price per mile. cout << "You got " << MilesPerGallon << " miles per gallon,\n"; cout << "and each mile cost $" << PricePerMile << "\n"; return 0; } When I run this program, the user input questions come up on my black screen, but once the 'cost per gallon' entry is made, the program reverts to the code, and moves out of the 'run' procedure. What is going wrong?? (2)When I start my students off with a simple program: // braces.cpp #include int main() { int i; // declare an integer for the loop for(i = 1; i <= 3; i++) { cout << i << '\n'; if(i == 3) { cout << "This is the last time\n"; cout << "i equals three\n"; } // end of if statement } // end of for loop return 0; } // end of main function once compiled, the program shown above flashes the black screen and goes back to the code. Help? . 0