-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathC++ Function Syntax definition.cpp
More file actions
79 lines (60 loc) · 1.6 KB
/
C++ Function Syntax definition.cpp
File metadata and controls
79 lines (60 loc) · 1.6 KB
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
[PROGRAM] : C++ Functions
[AUTHOR] : Saddam Arbaa
[Email] : <saddamarbaas@gmail.com>
A function is a block of code which only runs when it is called.
we can pass data into a function. which is known as parameters,
Syntax
void myFunction() {
// code to be executed
}
*/
#include <iostream>
using namespace std;
// Function declaration
void myFunction();
// Function declaration
void sayHello();
// Function declaration
void func() ;
// the main Function
int main()
{
myFunction(); // call the function
myFunction(); // call the function again
myFunction(); // call the function again
myFunction(); // call the function again
sayHello(); // call the function
func(); // call the function
func(); // call the function
func(); // call the function
return 0;// signal to operating system everything works fine
}/** End of main function */
/**
Function definition
I Create a function named my function take
no parameter print "Hello my name is saddam" */
void myFunction()
{
// the body of the function (definition)
cout << "Hello my name is saddam!" << endl;
}
/**
Function definition
I Create a function named my sayHello take
no parameter print "Hello " */
void sayHello()
{
cout << "Hello!" << endl;
}
/**
Function definition
I Create a function named my func take no parameter */
void func()
{
static int i = 0; //static variable declaration
int j = 0; //local variables declaration
i++; // increment i by one
j++; // increment j by one
cout<<"i = " << i<<" and j = " <<j<<endl;
}