TODAY JAVA SCHOOL

In java school, programming, design, computer general knowledge, web application, software, web services, social media, digital marketing, oops, concept of programming language, oops feature, console media, graphics medium, first programming, c, c ++ , Java, PHP, SQL, MySQL, HTML, HTML_5, J_query, JavaScript, Bootstrap, Framework, images with logos, examples, shared and explained.

https://www.amazon.in/b?node=26373545031&linkCode=ll2&tag=1234567801cdb-21&linkId=3b9882431b00409b44141e0344b35a15&language=en_IN&ref_=as_li_ss_tl

Breaking

Sunday 28 June 2020

Default Arguments In C++ Function | Default Arguments In C++ Function Example| Default Arguments In C++ Function Program | Default Arguments In C++ Function In Hindi

Default Arguments In C++ Function

The default arguments are used when you provide no arguments or only few arguments while calling a function. The default arguments are used during compilation of program. 

image of Default Arguments In C++ Function
Fig: Default Arguments In C++ Function

Program:

#include<iostream.h>

class BCA;

int sum(int a, int b=10, int c=20);

int main()

{

cout<<sum(1)<<endl;

 cout<<sum(1, 2)<<endl;

cout<<sum(1,2,3)<<endl;

return 0;

}

int sum(int a, int b, int c)

{

int z;

z=a+b+c;

return z;

}

Output:

31

23

6

 

No comments:

Post a Comment