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

C assignment , 1. Create text a file with the name "myemail" that has a sin...

1. Create text a file with the name "myemail" that has a single line in it, consisting of your email address. Something like "[email protected]" (or your hotmail or gm

Decodethecode, decode smugglers are very smart in day by day

decode smugglers are very smart in day by day

What are the types of control structures in programming, What are the vario...

What are the various types of control structures in programming? - Primarily there are 3 types of control structures in programming: Sequence, Selection and Repetition. - Se

Give example of the for loop, The for Loop For loop is the controlled f...

The for Loop For loop is the controlled form of loop. The general format of this : for( initialize ; test ; update)                  {                     statements;

C program, what will be the c program for ideal gas equation.

what will be the c program for ideal gas equation.

Implement a algorithm to verify if the link list , Implement a Algorithm to...

Implement a Algorithm to verify if the link list is in Ascending order? A: template bool linklist::isAscending() const{ nodeptr ptr = head; while (ptr->_next)

Program for function in cpp, Question Write a program using c++ for the...

Question Write a program using c++ for the above function , at a= 1000, b=10 -3 ,10 -2 ,10 -4

''c'' programme, Write a ''C'' program to accept any 3 digit integer number...

Write a ''C'' program to accept any 3 digit integer number from the keyboard and display the word equivalent representation of the given number.

Program that predicts users age, Program: Write a program that predicts...

Program: Write a program that predicts users' age (0-128 years old) with at most 7 questions. The game starts with asking the user whether he/she is younger or older than G (an

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