C++ (In computer science)

C++ (In computer science)

C++ is a general purpose programming language as an evolution of the C language by inserting object-oriented programming.

In computer science, C++ is a general purpose programming language originally developed by Bjarne Stroustrup in Bell Labs in 1983 as an evolution of the C language by inserting object-oriented programming; over time it has had notable evolutions, such as the introduction of abstraction with respect to type.

The language was standardized in 1998 (ISO/IEC 14882:1998 "Information Technology - Programming Languages - C++", updated in 2003). C++11, also known as C++0x, is the standard that supersedes the 2003 revision. After a minor revision in 2014, a new version of the standard (known informally as C++17) was released in 2017. The latest version of the standard (C++20) was released in 2020.

C++ is the younger brother of C and is still one of the most used programming languages today accompanied by C, C#, Python, Java and JavaScript.

Difference of decimals

Simple program that asks the user to enter two decimals, makes the difference and displays the result.

C++ (as well as C to the C99 standard) implements single line comments via double slash: //. Comments on multiple lines use the same syntax as in C, ie: /* (comment) */.

#include <iostream> // per std::cout, std::cin e std::endl

using namespace std;

int main()
{
    // Inserimento della stringa sullo stream di output standard (stampa il
    // messaggio a video) std::endl, oltre ad inserire una nuova linea sullo
    // stream, svuota anche il buffer
    cout << "scrivi numero decimale" << endl;

    // Definizione di una variabile e del relativo tipo (decimale)
    // Non è importante che le definizioni siano all'inizio del blocco di codice
    int numero1;

    // Lettura dallo stream standard di input di un decimale da memorizzare
    // variabile "numero1"
    cin >> numero1;

    cout << "Inserire un altro numero decimale" << endl;
    int numero2;
    cin >> numero2;

    // La variabile "differenza" viene inizializzata con la differenza dei numeri letti
    int differenza = numero1 - numero2;
    cout << differenza << endl;

    return 0;
}