-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicRefrence.cpp
More file actions
51 lines (34 loc) · 922 Bytes
/
basicRefrence.cpp
File metadata and controls
51 lines (34 loc) · 922 Bytes
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
#include <iostream>
using namespace std;
int main() {
cout << "Hello World!\n";
//Data types: Boolean, Characters(single character), Integers, Float
int num = 5;
//Arrays syntax: "Data Type" Array_name[num of elements]
int nums[3];
//Strings - 2 ways: C-style - collection of characters in an array/or string object
string str = "Coffee";
//if - else - ex.
if(num == 5){
cout<<"That is the number";
}
else{
cout<<"That is not the number";
}
//for loop - ex.
for(int i=0;i<10;i++){
cout<<"Hello World!";
}
//while loop - ex.
while (num < 10){
cout<<num<<endl;
num++;
}
//casting
int number = 5;
double nume = static_cast<double>(number);
auto product = nume * 21 + 7.5; //becomes a double due to casting to double
cout<<product;
return 0;
}
//function syntax: type(void or return type) function_name(parameters)