Skip to main content

Declaration Of Variables

Declaration Of Variables:

                                             Assigning the name and data type that a variable can hold is called declaration of the variable.All variables that are used in a program are declared using variable declaration statement.

             The syntax to declare a variable in c++ is:

             type list of variables;
where

type:
         specifies data type of variables.For example,it may be int,float,etc.

list of variables:
                       specifies a list of variables separated by commas. In a single statement more than one variables,separated by commas, of same data type can b declared.
                     
                      Different statements are used to declare variables of different data type.

                      For example, to declare variables"abc","xyz","w"and "A" of integer  type  the statement is written as:

       int abc ,xyz ,d w,A;

     To declare variables a and xy as int type,w as float type,nm as string type of 15 characters and sum as double, the statments are written as:


    int a,xy;
   
   float b;

   char nm [15];

   double sum;

Comments

Popular posts from this blog

Data types in c++

DATA TYPES IN C++:                                        The variable  type specifies the type of the data that can be stored in it. Each variable is declared by its types.            c++ have five basic data types.These data type are:  int                               Integer float                             Floating point double                         Double Precision char                             Characters bool                             Boolean                          The first four data types are also available in c language.The bool is data type a new addition in c++ THE int DATA TYPE:                                         the int represents the integer data.It is used to declare integer type variables.                                    An integer is a whole number,i.e a number without a fraction or a decimal point.For example,645,230,-8 and 501 are integers.                                     The range of values that can  be stored

Programs

PROGRAM 1: #include<iostream> using namespace std; int main() {    cout<<"HELLO WORLD";    return 0; } OUTPUT OF THE PROGRAM: HELLO WORLD                 ............................................................................................................................. PROGRAM 2: #include<iostream> using namespace std; int main() {    cout<<"c++ is best language";    return 0; } OUTPUT OF THE PROGRAM: c++ is best language      .............................................................................................................................                    

Writing c++ program

Introduction:                                       The source  code of a c++ program is stored on the disk with file extension cpp (cpp stands for  c plus plus) Structure of c++ programs:                                                       A c++ program consists of three main parts:  Preprocessor Directive     The main() function c++ statements Preprocessor Directives:                                         The instructions that are given to the compiler before the beginning of the actual program is called Preprocessor Directives also known  as compiler Directives Example:           #include<iostream> using namespace std; main() {    cout<<"<<Life is beautiful"; }