You are on page 1of 2

C++ is a general-purpose programming language that was developed in the early

1980s. It is an extension of the C programming language and provides additional


features such as object-oriented programming, generic programming, and exception
handling.

Here is a basic overview of the C++ language:

Basic Syntax
C++ programs are made up of one or more functions, which are blocks of code that
perform a specific task. The main function is the entry point of the program and is
where the execution of the program begins.

Here is the basic syntax for a C++ program:

#include <iostream>

int main() {

// Program code goes here

return 0;

The #include directive is used to include header files in the program. The
<iostream> header provides input and output streams (such as cin and cout) that
can be used to read from and write to the standard input and output streams.

The int main() function is the entry point of the program. The return 0;
statement indicates that the program has completed successfully.

Variables
Variables are used to store data in a C++ program. Variables have a type, which
determines the kind of data they can store, and a name, which is used to refer to the
variable in

Data Types
C++ has a variety of built-in data types that can be used to store different kinds of
data. Some of the most commonly used data types are:
 int: used to store integers (whole numbers)
 float: used to store floating-point numbers (numbers with a decimal point)
 double: used to store double-precision floating-point numbers (more precise
than float)
 char: used to store single characters
 bool: used to store boolean values (true or false)

Here is an example of how variables of different data types can be declared and
initialized in C++:

int x = 10;

float y = 3.14;

double z = 3.141592653589793;

char c = 'A';

bool b = true;

Operators
C++ provides a variety of operators that can be used to perform operations on
variables. Some of the most commonly used operators are:

 +: addition
 -: subtraction
 *: multiplication
 /: division
 %: modulus (remainder)

Here is an example of how operators can be used in C++:

int x = 10;

int y = 5;

int z = x + y; // z is 15

int a = x –

You might also like