Chapter 3
Hey friends Today on Technomantras I want to give the chapter 3 of C++ .in this chapter we will study about the concept of variables and how to initialize and declare them ? VARIABLE
variable is simply the name of the memory where we can store data.
For example:
#include<iostream.h>
#include<conio.h>
void main( )
{
clrscr( );
int a=10;
cout<<a;
getch( );
}
In the above program "a" is a variable that is assigned the value 25.I hope you people are clear about the meaning of variables.
Now the next concept is how to declare them and initialise them??
DECLARATION
It means simply declaring the variable such as in the above program I have declared A as a variable.
INITIALIZING
It means giving value to the variable.In the above Program the value given to a is 25.It is called Initializing.
Declare and initialise the variables as:
int a=10;
Declare and initialise the variables as:
int a=10;
-----OR-----
int a;
a=10;
int a;
a=10;
IMP. CONCEPTS REGARDING VARIABLES
1.Don't use space in the name of variables.
2.Variable name cannot start with a number but number can be part of the variable.
3.Underscore(_) can be used in the variable name.
4.The variable name should be logical.
5.At a time variable save only one value.
6.The variable names cannot be same even if the data types are different.
7.In case if user doesn't give any value to the variable then the variable is assigned a garbage value by the system.
For Eg.
Try
int a;
cout<<a;
System will provide some garbage value to the variable.
0 comments:
Post a Comment