- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariable.cpp
More file actions
Latest commit
52 lines (35 loc) · 1.13 KB
/
Copy pathvariable.cpp
File metadata and controls
52 lines (35 loc) · 1.13 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
#include<iostream>
#include<string>
#include<cmath>
usingnamespacestd;
intmain()
{
//init a variable
intuserAge(30);
doublepi(3.14);
booliLoveProgramming(true);
charaSimpleLettrer('m');
//display a variable
cout << "ur age is : " << userAge << endl;
cout << "the letter is : " << aSimpleLettrer << endl;
cout << " is love programming is : " << iLoveProgramming << endl << endl;
//give 2 or more names to a variable
intmyAge(29);
int& alsoMyAge(myAge);
cout << "I'm " << myAge << "old (variable)" << endl << endl;
cout << "I'm " << alsoMyAge << "old (ref to the variable)" << endl;
//cin
string userName;
cout << "what's your name ?" << endl;
//cin >> userName; will catch the first world only
getline(cin, userName);//using get line to catch all char from the user
cout << "your name is " << userName << endl;
//init a const variable
intconstmyAgeToday(29);
string constmyName("Max");
//use cmath example
int result = 16;
int newResult = sqrt(result);
cout << "sqrt of 16 : " << newResult << endl;
return0;
}