Read more than one value in cin statement - C++ Language Basics

C++ examples for Language Basics:Console

Description

Read more than one value in cin statement

Demo Code

#include <iostream>
using namespace std;
int main()//  ww  w  .  java 2s. c om
{
   int num1, num2, num3;
   double average;
   cout << "Enter three integer numbers: ";
   cin  >> num1 >> num2 >> num3;
   average = (num1 + num2 + num3) / 3.0;
   cout << "The average of the numbers is " << average << endl;
   return 0;
}

Result


Related Tutorials