C++ Program to Read an Integer and Character and Print on Screen

Here is a C++ program to read a character and Integer from user and print on screen. In this program, we will take an integer and character as input from user using cin stream and print it on screen using cout. This program helps in understanding basic input and output of C++ programming language.


C++ program to read and print an integer and character

#include <iostream>

using namespace std;

int main() {
    int val;
    char c;
    // Read input 
    cout << "Enter an Integer and a Character\n";
    cin >> val >> c;
    // Print on screen
    cout << "Entered Integer : " << val << endl;
    cout << "Entered Character : " << c;
    
    return 0;
}
Output
Enter an Integer and a Character
12 A
Entered Integer : 12
Entered Character : A

Recommended Posts
C++ Taking Input From User
C++ Program to Print a Sentence on Screen
C++ Program to Print Hello World
C++ Program to Check Whether a Character is Alphabet or Not
C++ Program to Check Whether a Character is Vowel or Not
C++ Program to Swap Two Numbers
C++ Program to Make a Simple Calculator
C++ Program to Find Factorial of a Number
C++ Program to Reverse Digits of a Number
All C++ Programs