flags of open operation c++
#include <iostream>
using namespace std;
int main() {
int x = 5;
int y = 3;
// Addition
int sum = x + y;
cout << "Sum: " << sum << endl;
// Subtraction
int difference = x - y;
cout << "Difference: " << difference << endl;
// Multiplication
int product = x * y;
cout << "Product: " << product << endl;
// Division
int quotient = x / y;
cout << "Quotient: " << quotient << endl;
// Modulus (Remainder)
int remainder = x % y;
cout << "Remainder: " << remainder << endl;
return 0;
}
Explanation:
- #include <iostream>
: Includes the Input/Output Stream Library.
- using namespace std;
: Declares that elements from the standard C++ library (such as cout
and endl
) are used in this code.
- int main() { ... }
: The main function where program execution begins.
- int x = 5;
and int y = 3;
: Declares and initializes two integer variables, x
and y
.
- int sum = x + y;
: Computes the sum of x
and y
.
- cout << "Sum: " << sum << endl;
: Outputs the sum.
- int difference = x - y;
: Computes the difference between x
and y
.
- cout << "Difference: " << difference << endl;
: Outputs the difference.
- int product = x * y;
: Computes the product of x
and y
.
- cout << "Product: " << product << endl;
: Outputs the product.
- int quotient = x / y;
: Computes the quotient of x
divided by y
.
- cout << "Quotient: " << quotient << endl;
: Outputs the quotient.
- int remainder = x % y;
: Computes the remainder of x
divided by y
.
- cout << "Remainder: " << remainder << endl;
: Outputs the remainder.
- return 0;
: Indicates successful completion of the main()
function.