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++

Define bitwise-and operator, Define Bitwise-AND Operator: &:? The bitwi...

Define Bitwise-AND Operator: &:? The bitwise-AND operator (&) compares every bit of its first operand to the corresponding bit of its second operand. If both bits are 1 the mat

Define structures in c++, Structures A structure is a user-defined data...

Structures A structure is a user-defined data type, which may have different data types as its members. Creating a structure is a two-part process. First, a structure template

Cin, how we use the cin command and why we use this command????

how we use the cin command and why we use this command????

Why should i employ new instead of truthful old malloc()?, Why should I emp...

Why should I employ new instead of truthful old malloc()? A: Constructors/destructors, type safety, overridability. Constructors/destructors: unlike malloc(sizeof(Fred)), new

Stack operations - c++, Stack operations - C++: Write a program to def...

Stack operations - C++: Write a program to define basic stack operations in c++. int Stack::push(int elem) {    int m = getmax();    if (top    {       put_

How can dereferencing the pointer this, Dereferencing the Pointer this ...

Dereferencing the Pointer this Sometimes a member function requires to make a copy of the invoking instance so that it can change the copy without affecting the original instan

When should you use multiple inheritance, There are 3 acceptable answers: "...

There are 3 acceptable answers: "Never," "Rarely "and" When the problem domain cannot be accurately modelled any other way."

Compiler design, Compiler Design - Limit In The Method Instructions

Compiler Design - Limit In The Method Instructions

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