- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Default Arguments in C++
In this tutorial, we will be discussing a program to understand default arguments in C++.
Default arguments are those which are provided to the called function in case the caller statement does provide any value for them.
Example
#include<iostream> using namespace std; //function defined with default arguments int sum(int x, int y, int z=0, int w=0){ return (x + y + z + w); } int main(){ cout << sum(10, 15) << endl; cout << sum(10, 15, 25) << endl; cout << sum(10, 15, 25, 30) << endl; return 0; }
Output
25 50 80
Advertisements
To Continue Learning Please Login
Login with Google