EC-237 Computer Systems & Programming Lab Report - 02: Fatima Hasnain ME-46-A
EC-237 Computer Systems & Programming Lab Report - 02: Fatima Hasnain ME-46-A
LAB REPORT – 02
FATIMA HASNAIN
ME-46-A
Lab Tasks
TASK 1:
Write a C++ program that should take two integer inputs (already initialized) and use the
arithmetic operators to compute and display the sum, difference, product, and division of
the two numbers. Make sure to display the results of all the operations one by one. Make
sure to include comments for each line of the code to explain what it does.
CODE:
cout << "Sum: " << sum << endl; //displaying output
cout << "Difference: " << diff << endl;
cout << "Product: " << product << endl;
cout << "Division: " << div << endl;
OUTPUT:
TASK 2:
Write a C++ program that should take two integer inputs from the user. Using the modulus
operator, compute the remainder of the division of the first number by the second and
display the result. Make sure to include comments for each line of the code to explain what
it does.
CODE:
cout << "The Remainder Is: " << modulus << endl; //displaying output
OUTPUT:
TASK 3:
Write a C++ program that should take two integer inputs (already initialized) and check if
the numbers are equal or not using the equal to (==) and not equal to (!=) operators. For
both comparisons, display the result directly, with 1 representing true and 0 representing
false. Make sure to include comments for each line of the code to explain what it does.
CODE:
OUTPUT:
TASK 4:
Write a C++ program that should take two integer inputs from the user and use the greater
than (>), less than (<), and equal to (==) operators to compare the two numbers. For each
comparison, print the boolean result directly, with 1 representing true and 0 representing
false. Make sure to include comments for each line of the code to explain what it does.
CODE:
int main()
cout << "Is a Greater Than b: " << (a > b) << endl; //using boolean operators
cout << "Is a Less Than b: " << (a < b) << endl;
OUTPUT:
HOME TASK
TASK 5:
Write a C++ program to create a simple calculator that performs basic arithmetic operations
(addition, subtraction, multiplication, division, and modulus) on two numbers provided by the
user. The program should perform all the operations. Use boolean operators to check if the
first number is greater than, less than, or equal to the second number, and display the
comparison result. Simply calculate and display the results of all the operations for the given
input numbers.
CODE:
#include <iostream>
using namespace std;
int main()
{
int x, y;
cout << "Enter The First Integer ";
cin >> x; //taking first integer as input from user
cout << "Enter The Second Integer ";
cin >> y; //taking second integer as input from user
cout << "Is x Greater Than y: " << (x > y) << endl; // using boolean operators
cout << "Is x Less Than y: " << (x < y) << endl;
cout << "Is x Equal To y: " << (x == y) << endl;
}
OUTPUT: