Lab 2 - Arithmetic Statement

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

EED420 Computer Systems

Lab 2 – Arithmetic Statement

Lab Rules

❖ No copying of coding.
❖ Only 30% plagiarism is allowed (more than 30% results to a zero mark in that lab).
❖ Individual or Pair Submission (lab supervisor will inform)
❖ Marks will be given for correct comments, concise coding, correct use of commands and
should have an appealing structure.

Introduction
The arithmetic statements are the ADD, MODULUS, DIVIDE, MULTIPLY and SUBTRACT statements.

Objectives
The objective of this lab is to understand and practice working with arithmetic statements in C++.
Participants will gain hands-on experience with basic arithmetic operations and expressions.

Lab Exercises

Task 1 – Arithmetic Operators

Implement a program that computes the following operations.

- Addition
- Subtraction
- Modulus
- Multiplication
- Division

Your program must prompt the user to enter 2 numbers and then the result of each operation must
be printed out.

(note: you can have 5 separate program files)

Task 2 – Arithmetic Expressions and Precedence

According to the coulomb force law, the electric force between charged particles of charge 𝑄1 and 𝑄2
coulombs, that are a distance, r, meter apart, is given by the following formula.

𝑄1 𝑄2
F=
4𝜋𝜀𝑟 2
Where 𝜀 = 8.854 𝑥 10−12 farads/meter.

Page 1 of 2
EED420 Computer Systems

Write a program that calculates the force on a pair of charged particles, based on the user input 𝑄1
coulombs and 𝑄2 coulombs, and r meters, and then computes and displays the electric force.

Task 3 – Electrical Problem

Consider the following circuit.

You are to make a program that.

- Calculates the total resistance of the circuit (user must be prompted for the values of R1,R2
and R3)
- Given the value of V is 36V, calculate the voltage drop at R3.

All the best

Page 2 of 2

You might also like