-
Notifications
You must be signed in to change notification settings - Fork 0
/
12.fuction in cpp.cpp
60 lines (46 loc) · 914 Bytes
/
12.fuction in cpp.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#include <iostream>
using namespace std;
// function are used for use the same code multiple times
// types of fuction
// 1.void fuction does not return anything
// 2.parameterised
// 3.non parameterised
// declaration of fuction
/* paramater type
return type function name(parameter 1,para 2)
{
code block
}
int calculation(int a , int b)
{
return a+b;
}
return type is int
function name is calculation
parameter type is int
parametrs are a and b
inside the function we return the adition of a and b
*/
// void function doest return anything
void print(int n)
{
for (int i = 0; i < n; i++)
{
cout << "hello"<<endl;
}
}
// parameterised fuction return some value
int sum(int a,int b)
{
return a+b;
}
int main()
{
// fuction call
int n = 5;
print(n);
// fuction call
int s = sum(1,5);
cout<<s;
return 0;
}