Functions and function prototypes in C++

website link: https://techifyshreyansh.blogspot.com/2021/04/lecture-16-function-and-function.html

In this lecture I have discussed about the FUNCTIONS in C++. and also talk aboutFUNCTION PROTOTYPES. In this we learn how to call a FUNCTION in C++.

And what are function prototypes and how to execute it in our programs.

LECTURE LINK: https://youtu.be/XAHUXrUMq5U

#include<iostream>

using namespace std;

//****************function prototype********************

//syntax: type function_name(arguments);

//int sum(int a , int b); // — — — — ->>> acceptable

int sum(int, int);// — — — — — — ->>>acceptable…… means both are acceptable

void g(void);

int main(){

int num1, num2;

cin>>num1;

cin>>num2;

// num1 and num2 are actual arguments

cout<<”the sum is “<<sum(num1, num2);

g();

return 0;

}

int sum(int a, int b){

//formal parameters a and b taking value from actual parameters num1 and num2

int c= a+b;

return c;

}

void g(){

cout<<”\nhello im shreyansh “<<endl;

}

--

--

TECHIFY SHREYANSH
0 Followers

Techify shreyansh is attempt to teach coding techniques to people in short time which took me ages to learn.My blog is: https://techifyshreyansh.blogspot.com/