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

What does extern "c" int func(int *, A: This will turn o_ "name mangling" f...

A: This will turn o_ "name mangling" for func so that one can connect to code compiled by a C compiler.

Function returning object, F u nction Returning Object: This program ...

F u nction Returning Object: This program is like to the previous program except the function returns object.  The main rule to be remembered is the function returning obj

Work related, Make the following 3 functions work by filling in appropriate...

Make the following 3 functions work by filling in appropriate C code. This file 1. // Write a function to count the number of particular characters in a string. // Do not use a

Board coloring, coloring of elements in matrix form inm particular matrix.t...

coloring of elements in matrix form inm particular matrix.the color should not match with another color.

Abcd, #question.gsdjfhjhjfkfk.

#question.gsdjfhjhjfkfk.

Decodethecode, how to decode the numerals to string..

how to decode the numerals to string..

Problem : Change to palindrome, A palindrome is a string that reads the sam...

A palindrome is a string that reads the same from both the ends. Given a string S convert it to a palindrome by doing character replacement. Your task is to convert S to palindrome

#tit, Write a program to find the area under the curve y = f(x) between x =...

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b. The area under a curve between two points can b

Pseudocode , Record separation problem Let us assume that a particular data...

Record separation problem Let us assume that a particular database program manages a simple mailing list which consists of one record for each person on the list, and a number of f

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