Friday, January 6, 2012

Basic input/output: cin & cout

Example:
Basic input/output: cin & cout
// ConsoleApplication1.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
 int input1;
 float input2;
 char input3;
 
 char retry;
 do{
  cout << "Hello! Enter: int, float and char" << endl;
  cin >> input1 >> input2 >> input3;
  cout << "You enter: " << endl;
  cout << input1 << endl;
  cout << input2 << endl;
  cout << input3 << endl << endl;

  cout << "Retry? <y>" << endl;
  cin >> retry;
 } while ((retry==(char)'y')||(retry==(char)'Y'));

 system("PAUSE");
 return 0;
}


No comments:

Post a Comment