Professional Documents
Culture Documents
Laboratory Report 13
Laboratory Report 13
LABORATORY REPORT
IN
COMPUTER FUNDAMENTALS AND
PROGRAMMING
OBJECTIVE: To design a program that will ask the user for numbers and will perform selected
arithmetic operation using If..Else Condition.
PROCEDURE: Using If…Else Conditional Statements, design a program that will ask the user
for two numbers and which operation they would like to choose – addition, subtraction,
multiplication, division, or average.
Sample Output:
#include <iostream>
int main() {
// Declare variables
char operation;
if (operation == 'a') {
std::cout << "The sum of " << num1 << " and " << num2 << " is " << num1 + num2 << "."
<< std::endl;
std::cout << "The difference of " << num1 << " and " << num2 << " is " << num1 - num2
<< "." << std::endl;
std::cout << "The product of " << num1 << " and " << num2 << " is " << num1 * num2 <<
"." << std::endl;
if (num2 != 0) {
std::cout << "The quotient of " << num1 << " and " << num2 << " is " << num1 / num2
<< "." << std::endl;
} else {
std::cout << "The average of " << num1 << " and " << num2 << " is " << (num1 + num2) / 2
<< "." << std::endl;
} else {
return 0;
CONCLUSION:
OBJECTIVE: To design a program that will ask the user for numbers and will perform selected
arithmetic operation using Switch…Case Condition.
PROCEDURE: Using Switch…Case Conditional Statements, design a program that will ask the
user for two numbers and which operation they would like to choose – addition, subtraction,
multiplication, division, or average.
Sample Output:
CONCLUSION: