0% found this document useful (0 votes)
3 views5 pages

LabC++TheFourthHomework

The document contains C++ code snippets for three questions. The first question prints two integers, the second calculates and outputs the sum, difference, product, and division (if applicable) of two user-input integers, and the third compares two integers to either increment the smaller one or print their product if they are equal. Each code snippet is structured within its own main function.

Uploaded by

maher sawsak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

LabC++TheFourthHomework

The document contains C++ code snippets for three questions. The first question prints two integers, the second calculates and outputs the sum, difference, product, and division (if applicable) of two user-input integers, and the third compares two integers to either increment the smaller one or print their product if they are equal. Each code snippet is structured within its own main function.

Uploaded by

maher sawsak
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

//Name Maher Sawsak.

// Student Number :220208721

// question (1)

#include <iostream>

using namespace std;

int main() {

int A = 10;

int B = 20;

cout << A << endl << B << endl;

return 0;
}

//// question(2)

#include <iostream>

using namespace std;

int main() {

int a, b;

cin >> a >> b;


int sum = a + b;

int diff = a - b;

int prod = a * b;

cout << sum << " " << diff << " " << prod << " ";

if (b != 0) {

double div = static_cast<double>(a) / b;

cout << div;

else {

cout << "DivisionByZero";

cout << endl;

return 0;

}
// question (3)

#include <iostream>

using namespace std;

int main() {

int a, b;

cin >> a >> b;

if (a < b) {

a += 1;

cout << a << endl;

else if (b < a) {

b += 1;

cout << b << endl;


}

else {

int product = a * b;

cout << product << endl;

return 0;

You might also like