Basic

Write a Cpp program to print an integer

Write a Cpp program to print an integer

In this tutorial, we will discuss a simple concept of Write a Cpp program to print an integer

In this program, we are going to learn about how to print an integer number entered by the user in the Cpp programming language.

Cpp program to print an integer

The value is stored in a variable num using cin and is displayed on the screen using cout statements

Program 1

Cpp program to print an integer – entered by the user

#include <iostream>

using namespace std;

int main()
{
    int num;//variable declaration
    
    cout << "Enter an integer" << endl;
    
    cin>>num;
    
    cout<<"You entered :"<<num;
    return 0;
}

When the above code is executed, it produces the following results

Enter an integer
65
you entered : 65

In the C++ program, the user can enter a value using cin and that value is stored in a variable named num. then prints that value using display statements(cout) in C++ language

In this program, cout provide a piece of information to the user  for entering an integer value

 cout << "Enter an integer" << endl;

The cin  reads an input data from the user and stores in variable num

cin>>num;

Finally, the value stored in the variable num is displayed on the screen  using cout

cout<<"You entered :"<<num;

Recommended post

Write a C program to print an integer

Write a Cpp program to print an integer

Write a Python program to print an integer

write a Java program print characters of a string

write a C++ code to print characters of a string

write a C Code to print characters of a string

write a Java program to print characters of a string

 

Suggested for you

C++ data type

C++ Variables

C++ operator

Write a C program to print an integer
Write a Python program to print an integer
Karmehavannan

I am Mr S.Karmehavannan. Founder and CEO of this website. This website specially designed for the programming learners and very especially programming beginners, this website will gradually lead the learners to develop their programming skill.

Recent Posts

C# inverted full pyramid star pattern

C# inverted full pyramid star pattern In this article, we will discuss the concept of…

3 weeks ago

C# Full Pyramid star pattern program

C# Full Pyramid star pattern program In this article, we will discuss the concept of…

1 month ago

Program to count vowels,consonants,words, characters and space in Java

Program to count vowels, consonants, words, characters and space in Java In this article, we…

1 month ago

How to print multiplication table using Array in C++ language

How to print multiplication table using Array in C++ language In this post, we will…

1 month ago

C Program to multiplication table using Array

C Program to multiplication table using Array In this tutorial , we will discuss about…

2 months ago

Java program to check odd or even using recursion

Java program to check odd or even using recursion In this tutorial, we discuss a…

2 months ago