OOPortal
RationalDB Database Design
prev next prev next
  Course navigation
 
Lesson 3
Objective
C++ Input
Convert a simple input/output program in C to C++.
   
Take a look at simple input in C++.
We will write a program that prompts the user for a value in miles. The program then converts this value to kilometers and prints it out.
Variables and declarations
Constants
Our conversion program uses variables capable of storing integer values and real values, as well as const variables. Notice that in C++, all variables must be declared before they can be used, but unlike in C, they need not be at the head of a block.
Program dissection
Move your mouse cursor over the highlighted lines of code below for a pop-up discussion of their function.
Input Class
Using IO Stream Exercise
Click the Exercise link below to convert a simple input/output program in C to C++.
Using IO Stream Exercise
  Course navigation