Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Impara Writing Your First C++ Program | Getting Started
C++ Introduction
course content

Contenuti del Corso

C++ Introduction

C++ Introduction

1. Getting Started
2. Introduction to Operators
3. Variables and Data Types
4. Introduction to Program Flow
5. Introduction to Functions

book
Writing Your First C++ Program

The traditional first program in any programming language is often a simple program that outputs the message to the console.

Input and Output

The most common way to output information to the console is by using iostream library. It stands for input/output stream. As we already know, to add library to our program we have to include it.

h

include

copy
1
#include <iostream>

Character output

The cout stream is part of the iostream library and is used for standard output.

h

cout

copy
1
std::cout << "Message";
  • std::: it means that the identifier is part of the standard library, which is organized under the std namespace;

  • cout: stands for character output and is used to send output;

  • <<: it is used to insert data into the standard output stream.

Comments

Comments are used for documentation and do not affect program execution. There are two types:

  • Single-line comments: Begin with // and extend to the end of the line;
  • Multi-line comments: Enclosed between /* and */.
h

comment

copy
12
// Outputs the "Message" in a console std::cout << "Message";
Compito

Swipe to start coding

Write a program that outputs a custom message to the console. Ensure you include the necessary header file and use the correct syntax for displaying text.

  • Include the necessary header file for input and output operations.
  • Use std::cout to display a custom message.
  • End the statement with a semicolon (;).

Soluzione

cpp

solution

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 5
toggle bottom row

book
Writing Your First C++ Program

The traditional first program in any programming language is often a simple program that outputs the message to the console.

Input and Output

The most common way to output information to the console is by using iostream library. It stands for input/output stream. As we already know, to add library to our program we have to include it.

h

include

copy
1
#include <iostream>

Character output

The cout stream is part of the iostream library and is used for standard output.

h

cout

copy
1
std::cout << "Message";
  • std::: it means that the identifier is part of the standard library, which is organized under the std namespace;

  • cout: stands for character output and is used to send output;

  • <<: it is used to insert data into the standard output stream.

Comments

Comments are used for documentation and do not affect program execution. There are two types:

  • Single-line comments: Begin with // and extend to the end of the line;
  • Multi-line comments: Enclosed between /* and */.
h

comment

copy
12
// Outputs the "Message" in a console std::cout << "Message";
Compito

Swipe to start coding

Write a program that outputs a custom message to the console. Ensure you include the necessary header file and use the correct syntax for displaying text.

  • Include the necessary header file for input and output operations.
  • Use std::cout to display a custom message.
  • End the statement with a semicolon (;).

Soluzione

cpp

solution

Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Tutto è chiaro?

Come possiamo migliorarlo?

Grazie per i tuoi commenti!

Sezione 1. Capitolo 5
Switch to desktopCambia al desktop per esercitarti nel mondo realeContinua da dove ti trovi utilizzando una delle opzioni seguenti
Siamo spiacenti che qualcosa sia andato storto. Cosa è successo?
some-alt