A Function is a collection of statements that are grouped together to perform an operation. A function in C++ is a block of code that, When the function is invoked from any part of the program, it all executes the codes defined in the body of the function. The default argument is a value provided in a function declaration that is automatically assigned by the compiler if the caller of the function doesn't provide a value for the argument with a default value. In case any value is passed the default value is overridden.
The program demonstrates a function with default arguments in C++, where the function has parameters with default values that can be omitted in function calls.
#include<iostream> using namespace std; // Default Argument Function void biodata(string name,int age,string city="Salem") { cout<<name<<" is from "<<city<<" and age is "<<age<<endl; } int main() { biodata("Ram",25); biodata("Sam",22,"Namakkal"); return 0; }
Ram is from Salem and age is 25 Sam is from Namakkal and age is 22To download raw file Click Here
Learn All in Tamil © Designed & Developed By Tutor Joes | Privacy Policy | Terms & Conditions