Professional Documents
Culture Documents
Programming Fundamentals 07
Programming Fundamentals 07
PROGRAMMING
LECTURE #07
C++ OPERATORS
#include <iostream>
using namespace std;
int main() {
int x = 5;
int y = 2;
cout << x % y;
return 0;
}
COMPARISON OPERATORS
int x = 5;
int y = 3;
cout << (x > y); // returns 1 (true) because 5 is greater than 3
ASSIGNMENT OPERATORS
#include <iostream>
using namespace std;
int main() {
int x = 10;
x += 5;
cout << x;
return 0;
}
LOGICAL OPERATORS
EXAMPLE
#include <iostream>
using namespace std;
int main() {
int x = 5;
int y = 3;
cout << (x > 3 && x < 10);
// returns true (1) because 5 is greater than 3 AND 5 is less than 10
return 0;
}