Mega Code Archive

 
Categories / C++ Tutorial / Data Types
 

Read integer from console using cin

#include <iostream>   using namespace std;      int main()   {     int length;    int width;        cout << "Enter the length: ";    cin >> length; // input the length      cout << "Enter the width: ";    cin >> width;  // input the width        cout << "The area is ";     cout << length * width;      return 0;   } Enter the length: 12 Enter the width: 12 The area is 144"