C++ program to take inputs from the user
ADVERTISEMENTS
C++ program to take inputs from the user. There are you will learn how to take inputs from the user in the C++ language.
Let us understand this example through the C++ program:
// C++ program to take inputs from the user
#include <iostream>
using namespace std;
int main() {
int p;
float q;
char r[1024];
cout << "Enter the integer value::\n";
cin >> p;
cout << "Enter the float value::\n";
cin >> q;
cout << "Enter the string value::\n";
cin >> r;
cout << "\nThe integer input is:\n" << p << "\n";
cout << "\nThe float input is:\n" << q << "\n";
cout << "\nThe string input is:\n" << r << "\n";
return 0;
}
Output:
Enter the integer value::
5
Enter the float value::
7.5
Enter the string value::
hello
The integer input is:
5
The float input is:
7.5
The string input is:
hello