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

  • Write a program in C++ to read a character and Integer from user and print on screen.
  • How to read integer and character in C++ programming language.

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

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 a number and a character fron user 
and print it on screen
*/
#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 Find Largest of Three Numbers
C++ Program to Check Leap Year
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