forked from paruldh/dev_project
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvariables.cpp
More file actions
38 lines (32 loc) · 946 Bytes
/
variables.cpp
File metadata and controls
38 lines (32 loc) · 946 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
#include <iostream>
using namespace std;
int main()
{
int num = 15;
num = 16;
// Note that if we assign a new value to an existing variable, it will overwrite the previous value:
float dec = 15.66;
char alpha = 'd';
string text = "My name is program";
bool test = false;
cout<< num << endl;
cout<< alpha << endl;
cout<< text << endl;
cout<< test << endl;
// The cout object is used together with the << operator to display variables. To combine both text and a variable, separate them with the << operator:
cout<<"My age is "<<num<<" years old";
// we can add variables as well
int x = 10;
int y = 12;
int sum = x + y;
int sub = x - y;
int mut = x*y;
double div = x/y;
cout<<x << endl;
cout<<y << endl;
cout<<sum << endl;
cout<<sub << endl;
cout<<mut << endl;
cout<<div << endl;
return 0;
}