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
why oops

d 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. Necklaces

Can I explicitly call a destructor if I've allocated my object with new?

Produce data from fixed OCR areas scanned. Project Description: Project is to design software which can use character recognition only on certain areas of scanned puff's/ jpe

Explain Rules for constructing variable names? The Rules for constructing variable names : a) A variable name is any combination of alphabets, 0 to 9 digits and undersc

Classify computer systems according to capacity. How they are different from computers according to the classification of technology. Provide comparative study also.

algorithm to prepare mark sheet of a student by inputing name,branchcode,semester,register no,5 marks of students and total mark of student

Consider the following example: int max(int x, int y)                  {                                 return ( x > y) ? x : y ;                  }   float max

There are ''''n'''' ants on a ''''n+1'''' length rod. The ants are numbered from 1 to n and are initially placed at positions starting from position 1 till position n. They are mov

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