C++ Input and Output Explained for Beginners











 C++ input and output is used to take data from the user and show output on the screen.

In C++, we use:

  • cin → to take input

  • cout → to display output

  • Example Program

  •  #include <iostream>
    using namespace std;
    int main() {
        int a;
        cout << "Enter a number: ";
        cin >> a;
        cout << "You entered: " << a;
        return 0;

  • 📌 Explanation:

    • cout prints message

    • cin takes value from keyboard

    • >> is insertion operator

    • << is extraction operator

Comments

Popular posts from this blog

C++ Programming for Beginners – Step by Step Guide

If-Else Statement in C++

Variables and Data Types in C++