-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththeorem4.cpp
More file actions
70 lines (50 loc) · 1.56 KB
/
theorem4.cpp
File metadata and controls
70 lines (50 loc) · 1.56 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
//! First we will start talking about functions
//? numbers x and y are my input, i want to calculate x + y;
int my_int = 3;
//grades --> got a list containing 50 grades
//goal add 1 to every grade
//grade = grade + 1
//* int addition (int x)
// the first int is the output type
// the second int is the input type
//! function
int addition(int x)
{
//? This function returns the input + 1
//* This function takes an input an arbitrary integer x
return x + 1;
}
//! variables
int my_int = 3;
int my_int = addition(my_int); //this variable calls a function
//returns 4
//! string function
string mystring = "hello ";
string mystring2 = "Sam";
string outputstring(string x, string y)
{
return x + y;
}
string mystring3 = outputstring(mystring, mystring2);
//* output would be "hello Sam"
//! void function
void print_title(string title)
{
cout << "A very good movie is: " + title << endl;
}
/*
! A function is a block of code which only runs when it is called.
! You can pass data, known as parameters, into a function.
! Functions are used to perform certain actions, and they are important for reusing code: Define the code once, and use it many times.
! C++ provides some pre-defined functions, such as main(), which is used to execute code. But you can also create your own functions to perform certain actions.
! To create (often referred to as declare) a function, specify the name of the function, followed by parentheses ():
*/
void myFunction()
{
// code to be executed
}
// Create a function
void myFunction()
{
cout << "I just got executed!";
}