---
title: "2.1 Printing Output Using std::cout"
description: "The standard output stream is used to display text and values on the console. In C++, the object `std::cout` represents the standard output stream provided by the `` library. This example demonstrates how to print text, variables, and multiple values…"
url: "https://edcret.in/docs/cpp-programming/input-and-output-cplusplus/2-1-printing-output-using-stdcout/"
updated: "2026-07-28"
category: C++ Programming / Input and Output
---

# 2.1 Printing Output Using std::cout

The standard output stream is used to display text and values on the console. In C++, the object `std::cout` represents the standard output stream provided by the `<iostream>` library.

This example demonstrates how to print text, variables, and multiple values using the stream insertion operator.

## Source Code

```
#include <iostream>

int main()
{
    int marks = 95;

    std::cout << "Programming in C++\n";
    std::cout << "Marks: " << marks << '\n';
    std::cout << "Status: Passed\n";

    return 0;
}
```

## Output

```
Programming in C++
Marks: 95
Status: Passed
```

## Explanation

- `#include <iostream>` includes the standard input/output stream library.
- `std::cout` is the standard output stream object used to write data to the console.
- The insertion operator (`<<`) sends data to the output stream.
- String literals enclosed in double quotes are written to the console exactly as they appear.
- Variables can be inserted into the output stream without using format specifiers.
- Multiple insertion operators can be used in a single statement to print text and variables together.
- `'\n'` inserts a newline character after the output.
- `return 0;` terminates the program successfully.
