five
#include <iostream>
int main() {
int num1 = 10;
int num2 = 5;
// Addition
int sum = num1 + num2;
std::cout << "Sum: " << sum << std::endl;
// Subtraction
int difference = num1 - num2;
std::cout << "Difference: " << difference << std::endl;
// Multiplication
int product = num1 * num2;
std::cout << "Product: " << product << std::endl;
// Division
int quotient = num1 / num2;
std::cout << "Quotient: " << quotient << std::endl;
// Modulus
int remainder = num1 % num2;
std::cout << "Remainder: " << remainder << std::endl;
return 0;
}
Explanation:
#include <iostream>
: Includes the input-output stream library that provides functionality for input and output operations.int main() { }
: Defines the main function where the execution of the program begins.int num1 = 10;
andint num2 = 5;
: Declares and initializes two integer variablesnum1
andnum2
with values 10 and 5 respectively.int sum = num1 + num2;
: Calculates the sum ofnum1
andnum2
and stores it in the variablesum
.std::cout << "Sum: " << sum << std::endl;
: Prints the value ofsum
along with the text "Sum: " to the standard output (console).int difference = num1 - num2;
: Calculates the difference betweennum1
andnum2
and stores it in the variabledifference
.std::cout << "Difference: " << difference << std::endl;
: Prints the value ofdifference
along with the text "Difference: " to the standard output.int product = num1 * num2;
: Calculates the product ofnum1
andnum2
and stores it in the variableproduct
.std::cout << "Product: " << product << std::endl;
: Prints the value ofproduct
along with the text "Product: " to the standard output.int quotient = num1 / num2;
: Calculates the quotient of dividingnum1
bynum2
and stores it in the variablequotient
.std::cout << "Quotient: " << quotient << std::endl;
: Prints the value ofquotient
along with the text "Quotient: " to the standard output.int remainder = num1 % num2;
: Calculates the remainder of dividingnum1
bynum2
and stores it in the variableremainder
.std::cout << "Remainder: " << remainder << std::endl;
: Prints the value ofremainder
along with the text "Remainder: " to the standard output.return 0;
: Indicates the successful termination of themain()
function and the program with a return status of 0.