• TestingDocs
TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

C++

C++ Input Statement

Overview

In this tutorial, we will learn the C++ input statement with the help of a sample program. The basic input object to take input from the standard input device is the cin object. 

C++ Input Statement

We use the cin input object and the >> operator to take the input from the standard device. The C++ standard input device is the keyboard.

For example, to take input to an integer variable called num, we can use the following statement

cin >> num; 

C++ Program

We will write a simple C++ program to understand the concept. We will write a simple program to read an integer value from the standard input device i.e keyboard, store the value in a variable and display the value to the computer screen.

 

/************************************
* C++ Input
* Filename: input.cpp
* Program to take user input from standard
* input device.
* C++ Tutorials - www.TestingDocs.com
**************************************/
#include 
using namespace std;
int main()
{
 int num; //declare integer variable
 cout << "Enter integer input:"; // User prompt cin >> num; // C++ Input Statement
 cout << "The value is =:" << num << endl;

 return 0;
} // end main

C++ Input Statement

Sample Output

Enter integer input:79
The value is =:79

—

C++ Tutorials

C++ Tutorials on this website:

https://www.testingdocs.com/c-coding-tutorials/

For more information on the current ISO C++ standard

https://isocpp.org/std/the-standard

Related Posts

g not found OpenSuse

C++ /

Install GCC C++ Compiler on OpenSuse

sum of digits c program

C++ /

Sum of Digits of a Number C++ Program

C++ Hello World Program

C++ /

C++ Hello World Program

C++ /

Object-Oriented Programming Language Examples

C++ /

Object-Oriented Programming Features

‹ C++ Intrinsic data types› C++ Output Statement

Recent Posts

  • How to secure your SQL Database: Tips and Tricks
  • Shaping the Future of Development: Exploring Key Trends in Software Engineering
  • Improving Java Performance with Multithreading
  • Difference between PHP and JavaScript?
  • Bing Conversation Styles
  • ChatGPT Introduction
  • Open Source AI Frameworks
  • Artificial Intelligence Tools
  • Top AI Music Applications
  • Top AI Website Design Tools

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com