How to Use the cin >> *num3; Statement in C++ - Comprehensive Guide

In this article, we’ll provide a comprehensive guide on how to use the cin >> *num3; statement in C++.

What is Cin >> *Num3;

In C++, the cin >> *num3; statement is used to read three numbers from the standard input. The numbers must be separated by whitespace. Its syntax can be seen as:

cin >> *num3;

What is the Purpose of Cin >> *Num3;

Cin >> *num3; is used to read three values from the input line which can be assigned to variables. This statement can be used to input strings, integers and floats.

How to Use Cin >> *Num3;

To use Cin >> *num3;, you need to have a set of three variables first.

For instance,

int n1, n2, n3;

You can then use the cin statement to read three numbers from the input and store them respectively in each variable.

For instance,

cin >> n1 >> n2 >> n3;

Examples of Cin >> *Num3;

Here are some examples of how Cin >> *num3; works:

Example 1

#include <iostream>
using namespace std;
 
int main()
{
   int number1, number2, number3;
   cout << "Enter three numbers separated by whitespace: ";
   cin >> number1 >> number2 >> number3;

cout << "You entered: " << number1 << ", " << number2
     << ", " << number3 << endl;
    
   return 0;
}

Output:

Enter three numbers separated by whitespace: 4 8 10
You entered: 4, 8, 10 

Example 2

#include <iostream>
using namespace std;
 
int main()
{
   float number1, number2, number3;
   cout << "Enter three numbers separated by whitespace: ";
   cin >> number1 >> number2 >> number3;

cout << "You entered: " << number1 << ", " << number2
     << ", " << number3 << endl;
    
   return 0;
}

Output:

Enter three numbers separated by whitespace: 25.60 41.90 92.0
You entered: 25.6, 41.9, 92

FAQ

What is the syntax for cin >> *num3; ?

The syntax for Cin >> *num3; is cin >> *num3;

Is it possible to read strings, integers and floats using cin >> *num3; ?

Yes, it is possible to read strings, integers and floats using Cin >> *num3; .

What does cin >> *num3; do?

Cin >> *num3; is used to read three values from the input line which can be assigned to variables.

Does cin >> *num3; require a set of variables?

Yes, to use Cin >> *num3; , you need to have a set of three variables first.

Is there a limit to the number of values that can be read using cin >> *num3;?

Yes, cin >> *num3; is limited to three values. To read more values than three, you can use a loop.

Understanding the Concept of Cin Object in C++ for Beginners | Simplilearn
The ‘C’ in C++ cin refers to ‘character’ and ‘in’ means ‘input’. Thus, cin means ‘character input’. The C++ cin object belongs to the istream class. Learn about the input sources it accepts and much more.

Great! You’ve successfully signed up.

Welcome back! You've successfully signed in.

You've successfully subscribed to Lxadm.com.

Success! Check your email for magic link to sign-in.

Success! Your billing info has been updated.

Your billing was not updated.