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

Write a recursive function with cylinders, I need to make a fractal trees i...

I need to make a fractal trees in OpenGL C++ . The method used is to write a recursive function with cylinders of different sizes and angles to create the tree trunk and branches.

Give a formal expression of the specification, A function REPAT is specifie...

A function REPAT is specified below. Function REPAT(c in Char, i in Int, s in mString) return in mString pre 1 ≤ i ≤ the length of s. post The returned value is a string identic

Thermodynamics, want to solve the thermodynamics problems on c language

want to solve the thermodynamics problems on c language

Define the float data type of c language, Define the Float Data Type of c L...

Define the Float Data Type of c Language? The float is used to define floating point numbers. The Floating point numbers are stored in 32 bits with 6 digits of precision. Eg

Cross platform clinet app for a vpn, Cross Platform Clinet app for a vpn ...

Cross Platform Clinet app for a vpn Project Description: We want a cross platform client app for VPN. The app must have the subsequent options below: 1. Must be an open

Some of the basic rules of cpp program, Ba s i c r u l e s o f C...

Ba s i c r u l e s o f C + + p r o g r a m : ·     I t m u s t h a v e o n l y o n e m a i n f u n c ti o n ·

Write a program for calculating value of an integer, Write a Program for Ca...

Write a Program for Calculating Value of an Integer? For a clear understanding of recursive function we shall see an illustration for calculating value of an integer. main() {

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