
- C++ Basics
- C++ Home
- C++ Overview
- C++ Environment Setup
- C++ Basic Syntax
- C++ Comments
- C++ Data Types
- C++ Variable Types
- C++ Variable Scope
- C++ Constants/Literals
- C++ Modifier Types
- C++ Storage Classes
- C++ Operators
- C++ Loop Types
- C++ Decision Making
- C++ Functions
- C++ Numbers
- C++ Arrays
- C++ Strings
- C++ Pointers
- C++ References
- C++ Date & Time
- C++ Basic Input/Output
- C++ Data Structures
- C++ Object Oriented
- C++ Classes & Objects
- C++ Inheritance
- C++ Overloading
- C++ Polymorphism
- C++ Abstraction
- C++ Encapsulation
- C++ Interfaces
How to Read and Print an Integer value in C++
Here we will see how to read integer from user and display in C++. To take input we will use the cin operator, and to display we will use cout operator. The syntax will be like −
Input −
int x; cin >> x;
Output −
int x = 110; cout << x;
Example
#include<iostream> using namespace std; int main(int argc, char const *argv[]) { int x; int y = 50; cout << "Enter some value: "; cin >> x; cout << "The given value is: " << x << endl; cout << "The value of y is: " << y; }
Output
Enter some value: 100 The given value is: 100 The value of y is: 50
- Related Articles
- How to Print an Integer in Golang?
- How to Print an Integer in Swift Program?
- How to read an input image and print it into an array in matplotlib?
- Java Program to Print an Integer
- Kotlin Program to Print an Integer
- How to convert an integer to an ASCII value in Python?
- C# Program to convert a Double to an Integer Value
- C++ Program to print unique integer pairs
- Java program to accept an integer from user and print it
- How to print integer array in android Log?
- Haskell Program to read an integer number from the user
- Print pair with maximum AND value in an array in C Program.
- How to convert an integer to hexadecimal and vice versa in C#?
- How to read an input value from a JTextField and add to a JList in Java?
- Assigning an integer to float and comparison in C/C++

Advertisements