0% found this document useful (0 votes)
34 views3 pages

C++ Programming Basics and Variables

The document discusses key aspects of C++ programs including: 1) The #include directive is used to include header files like iostream which contains declarations for standard input/output functions. 2) The main() function is where program execution begins and must be present in all C++ programs. It returns integer data type. 3) Important practices are using necessary header files, indentation, comments, and cout/cin for output/input.

Uploaded by

Jatin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
34 views3 pages

C++ Programming Basics and Variables

The document discusses key aspects of C++ programs including: 1) The #include directive is used to include header files like iostream which contains declarations for standard input/output functions. 2) The main() function is where program execution begins and must be present in all C++ programs. It returns integer data type. 3) Important practices are using necessary header files, indentation, comments, and cout/cin for output/input.

Uploaded by

Jatin
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CPP NOTES

 The #include directive tells the compiler to include a file and #include<iostream>. It tells the
compiler to include the standard iostream file which contains declarations of all the standard
input/output library functions.
 int main(): This line is used to declare a function named “main” which returns data of integer
type. A function is a group of statements that are designed to perform a specific task.
Execution of every C++ program begins with the main() function, no matter where the
function is located in the program. So, every C++ program must have a main() function.
 Important Points to Note while Writing a C++ Program:

 Always include the necessary header files for the smooth execution of functions. For
example, <iostream> must be included to use std::cin and std::cout.
The execution of code begins from the main() function.
It is a good practice to use Indentation and comments in programs for easy understanding.
cout is used to print statements and cin is used to take inputs.

VARIABLES
Variables in C++
Variables in C++ is a name given to a memory location. It is the basic unit of
storage in a program.
The value stored in a variable can be changed during program execution.
A variable is only a name given to a memory location, all the operations done
on the variable effects that memory location.
In C++, all the variables must be declared before use.
Rules For Declaring Variable
The name of the variable contains letters, digits, and underscores.
The name of the variable is case sensitive (ex Arr and arr both are different variables).
The name of the variable does not contain any whitespace and special characters (ex #,$,%,*, etc).
All the variable names must begin with a letter of the alphabet or an underscore(_).
We cannot used C++ keyword(ex float,double,class)as a variable name

You might also like