Professional Documents
Culture Documents
Operators and Loops: Daniel M. Ahiatrogah Regent University College September 2013
Operators and Loops: Daniel M. Ahiatrogah Regent University College September 2013
Loops
Daniel M. Ahiatrogah
Regent University College
September 2013
Recap of Preview Lesson
Dont use keywords as variables names
Give your variable meaningful names that reflect their
use.
Constants cannot be changed while the program is
running.
There are two ways of defining constants in C++ :
#define and using the const keyword
#define length 5
const int length = 5;
Const is a better way of defining a variable in C++.
int main()
{
int result, i = 4, j = 3;
result = i%j;
cout << result <<endl;
i++;
cout << i <<endl;
i++;
cout << i <<endl;
i++;
i++;
i--;
cout << i << endl;
system("pause");
return 0;
}
Regent University College of
Science and Technology 6
Relational Operators
== : equal to
!= : not equal to
> : greater than
>= : greater than or equal to
< : less than
<= : less than or equal to
0 0 0 0
0 1 0 1
1 1 1 1
1 0 0 1