Constant argument, C/C++ Programming

Define Constant argument:

The argument can be a constant argument The constant variable cannot be changed inside the function definition when the argument is declared as constant.

 

void f_const(int x, const int y);

void main( )

{int a10, b=20,c;

c =f_const(a, b); //The value of c is 30

}

int f_ref(int x, const int y)

{ //y=20; // Is invalid because y is declared as constant variable. return (x+y);

}

 

void f_const(int x, const int y=100);

void main( )

{int a=200, b,c;

c =f_const(a); //The value of c is 300

}

int f_const(int x, const int y)

{ //y=20; // Is invalid because y is declared as constant variable. return (x+y);

}

Posted Date: 9/20/2012 7:49:05 AM | Location : United States







Related Discussions:- Constant argument, Assignment Help, Ask Question on Constant argument, Get Answer, Expert's Help, Constant argument Discussions

Write discussion on Constant argument
Your posts are moderated
Related Questions
#Byteland county is very famous for luminous jewels. Luminous jewels are used in making beautiful necklaces. A necklace consists of various luminous jewels of particular colour. Ne

Explain Object-oriented programming Object-oriented programming (OOP) attempts to meet these requirements, providing methods for managing enormous complexity, achieving reuse o

Operators The variables, which are declared and explained, are the operands, which are operated upon by the operators. Operators specify what operations are to be performed on

flow chart for calculating the volume of sphere

write aprogram in c++ to overload +,-,=,++ operator using unary and friend function in a single program

A: A dangling pointer arises while you use the address of an object after its lifetime is end. It may occur in situations such as returning addresses of automatic variables from a

A parking garage charges a $2.00 minimum fee to park for up to three hours and an additional $0.50 per hour for each hour or part thereof over three hours. The maximum charge for a

write a c++ program to accept 3 numbers and find the largest of 3 numbers

C Program for FUNCTION OF COUNT THE CHARACTERS IN EACH WORD void count(char c[]); void main() {           char a[50];           int i=0;           clrscr();

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 ·