

- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- 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
- Related Questions & Answers
- Default arguments in Python
- What are default arguments in python?
- Default arguments and virtual function in C++
- How to arguments object with Rest, default, and destructured parameters in JavaScript?
- Required arguments in Python
- Keyword arguments in Python
- Named arguments in JavaScript.
- PHP Function arguments
- Command Line arguments in C#
- Variable Arguments (Varargs) in C#
- Command line arguments in Java
- Command Line Arguments in Python
- Variable-length arguments in Python
- Parameters & Arguments in JavaScript.
- Named Arguments in PHP 8
Advertisements