What Is A Header File?: Variables
What Is A Header File?: Variables
Header files contain definitions of Functions and Variables, which is imported or used into any C++
program by using the pre-processor #include statement. Header file have an extension ".h" which
contains C++ function declaration. Some of the header files:-
VARIABLES:-
A variable 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.
For example:-
C++ Data Types:-
All variables use data-type during declaration to restrict the type of data to be
stored. Therefore, we can say that data types are used to tell the variables the type
of data it can store. Every data type requires a different amount of memory.
The max(x,y) function can be used to find the highest value of x and y:
Example
cout << max(5, 10);
And the min(x,y) function can be used to find the lowest value of x and y:
Example
cout << min(5, 10);
Some of the other functions, such as sqrt (square root), round (rounds a number) and log
(natural logarithm), can be found in the <cmath> header file:
Example
#include <cmath>
cout << sqrt(64);
cout << round(2.6);
cout << log(2);
cout <<pow(2,3)
OUTPUT:-
0.693147