Define variable declaration in c++, C/C++ Programming

Assignment Help:

Variable Declaration

This declaration of variables in the C language is permitted only in the starting of their block, prior to executable program statements. In C++ declaration of variables can be interspersed with executable program statements. The scope id variables, though, remains  the same - the block in which they are declared.

e.g.

void main()

                 {

                  int x = 10;

                printf (" the value of x= % d\n",x);

                int y = 0;

 

for( int z= 0; z < 10; ; z++)              // variable declared

here.

                       {

y ++;

x ++;

                                  }

}

Although, a deviation from the old style of declaring all variables in the starting of the block, this does save some amount of memory, i.e., a variable is not given a memory unless the declaration statement. Also, as a variable can be declared just before using it is assume to give a better control over variables.

 


Related Discussions:- Define variable declaration in c++

Is there anything you can do in c++ which you cannot do in c, A: No. There ...

A: No. There is nothing you can do in C++ which you cannot do in C. In spite of everything

Develop an e commerce site, We need an E Commerce site likefifacointrader. ...

We need an E Commerce site likefifacointrader. you must have experience with that kind of work You have to show a sample of work like that site. Skills required are C Prog

Binary search in array: - c program, Binary search in array: - C program: ...

Binary search in array: - C program: Write a program in c to define binary search in array. void main()                 {                 clrscr();

String program, Write a C++ program which does the following: 1. Asks th...

Write a C++ program which does the following: 1. Asks the user to enter the following text "Four score and seven years ago there was a man named Joey Bagadonuts." 2. Save thi

We need to decompile ex4 to mq4, We need to Decompile ex4 to mq4 I have ...

We need to Decompile ex4 to mq4 I have three expert advisors for mt4, which I need to decompile to its original mq4 code. Skills required are C Programming, C++ Programming,

What do you mean by inheritance, Inheritance is the process of forming new ...

Inheritance is the process of forming new classes, called derived classes, from existing classes or base classes. The derived class inherits all the capabilities of the base class,

What is friend functions, Friend Functions One of the major features of...

Friend Functions One of the major features of OOP is information hiding. A class encapsulates data and methods to operate on that data in a single unit. The data from the class

Substitution model, (a) Write a procedure called (mult x y) that multiplies...

(a) Write a procedure called (mult x y) that multiplies two numbers x and y in a recursive manner using successive addition. Specifically, note that a x b = a + a + .... + a (b tim

Write Your Message!

Captcha
Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd