Simple C++ Program


C++ source code:




/*
 * A very simple C++ program demonstrating simple console I/O.
 */
 
 
#include <iostream>

using namespace std;




int main( ) {



    cout << "Please enter a number and a letter: " << flush;


    int a;
    char b;


    cin >> a >> b;
    cout << endl;



    cout << "The number you entered was: " << a << endl;
    cout << "The letter you entered was: " << b << endl;



    return 0;  // 0 to indicate normal termination of program
}


To compile:

 

 

 

 

 

 


To run:

 

Try running the program with the following user inputs:

87b
	
-12h	

9 b	

43.2a	

9    b    abc

y76