-
Notifications
You must be signed in to change notification settings - Fork 0
/
constants_N_MANIPULATORS_tute.cpp
48 lines (37 loc) · 1.79 KB
/
constants_N_MANIPULATORS_tute.cpp
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
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
//---------------------------------------------WITHOUT CONST KEYWORD--------------------------------------------------------
//VALUES OF VARIABLE INSIDE THE BLOCK ARE CHANGEABLE
/*int a=32;
cout<<"Value of a: "<<a<<endl;
a=23;
cout<<"Value of a: "<<a<<endl;*/
//-------------------------------------------------------------CONST KEYWORD-----------------------------------------------
//NOW USING CONST KEYWORD TO PREVENT CHANGING OF VVALUES IN C++
//const int a=32;
//cout<<"Value of a: "<<a<<endl;
//int a=34;
//cout<<"Value of a: "<<a<<endl;
//output==>> error: assignment of read-only variable 'a'
//USES- WHEN U DON'T WANT TO CHANGE THE VALUES ACCIDENTALY
//-------------------------------------------------------------------------------------MANIPULATORS----------------------------------
//MANIPULATORS(helps in formating data display)==endl,setw() in iomanip headerfile
/*int a=5, b=45, c=12345;
cout<<"The value of a without setw() is: "<<a<<endl;
cout<<"The value of b without setw() is: "<<b<<endl;
cout<<"The value of c without setw() is: "<<c<<endl;
cout<<"The value of c is: "<<setw(5)<<a<<endl;
cout<<"The value of c is: "<<setw(5)<<b<<endl;
cout<<"The value of c is: "<<setw(5)<<c<<endl;
output-->> The value of a without setw() is: 5
The value of b without setw() is: 45
The value of c without setw() is: 12345
The value of c is: 5
The value of c is: 45
The value of c is: 12345 */
//--------------------OPERATOR PRECEDENCE-----------------------------------------------------
return 0;
}