Skip to content
Menu
Code for Java c
  • Home
  • Java
    • Java Examples
    • Java tutorials
  • C
    • C tutorials
    • C Examples
  • C++
    • C++ Tutorials
    • C++ Examples
  • Python
    • Python Tutorials
    • Python Examples
  • About
    • About me
    • contact us
    • disclaimer
    • Privacy Policy
Code for Java c

Program to print an integer in C++ language

Posted on October 1, 2019October 1, 2019

Table of Contents

  • Program to print an integer in C++ language
    • C++ code to print an integer
    • C++ code to print an integer(entered by user)

Program to print an integer in C++ language

In this tutorial, we discuss the simple concept of Program to print an integer in C++ language

problem – How to write a program to print an integer in C++ language?

Program to print an integer in C++ language
Input-output

 

In this article, we are going to learn How to write a C++ program to print an integer

The following shows two different ways to How to write a C++ program to print an integer and there is an example given to each

The first Example is done by declared and initialized variable

The second Example is done through the user entered the value of the variables

C++ code to print an integer

Program 1

//C++ program to print an integer
#include <iostream>
#include <conio.h>
using namespace std;

int main()
{
    int num; //variable declaration
num=56;  //variablr initialization
    cout << "you declared: " << num<<endl;
    getch();
    return 0;
}

When the above code is executed it produces the following output

you Declared: 56

Method

C++ code to print an integer(entered by user)

Program 2

//C++ program to print an integer
#include <iostream>
#include <conio.h>
using namespace std;

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

When the above code is executed it produces the following output

Enter an integer to print:
100
you entered: 100

Method

  1. The program requires input from the user
  2. Then the user enters the input value
  3. The program will read the input using cin>> and stores the num variable
  4. Then, the program Display the value which  is in variable num using cout<<

 

Similar post

Write a C program to display an integer

Write a Java program to display an integer

Write a Python program to display an integer

 

Suggested post

Operator C++ language

Hello world program in C++ language

Data type in C++ language

 

Related

Recent Posts

  • Subtract two numbers using method overriding
  • PHP Star triangle Pattern program
  • Using function or method to Write temperature conversion : Fahrenheit into Celsius
  • Function or method:temperature conversion from Fahrenheit into Celsius – Entered by user
  • Write temperature conversion program: Fahrenheit into Celsius
  • How to write a program to convert Fahrenheit into Celsius

tag

Addition (6) Array (38) C++ language (91) C language (98) c sharp (23) Division (6) Function (29) if else (32) Java language (102) JavaScript (5) loops (137) Multiply (7) Oop (2) patterns (65) PHP (13) Python Language (38) Subtraction (7) temperature (20)

Archives

Categories

Address

Global information technology

Puloly south, PointPedro

Jaffna

Srilanka

©2025 Code for Java c | Powered by SuperbThemes