Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Exam (elaborations)

C++ SIMPLE CALCULATOR , ATM MACHINE CODE

Rating
-
Sold
-
Pages
21
Grade
A
Uploaded on
18-01-2026
Written in
2024/2025

Basic calculator CODE , ATM system CODE, Number Analysis CODE , Personal Finance Tracker CODE (ALL OF THEM HAS OUTPUTS )

Institution
Course

Content preview

BS(IT),SEMESTER #01, CP#LAB 05
NAME :UROOJ ASGHAR KHAN
ENROLLMENT # 02-135242-006

Task 1: Basic calculator
You are creating a basic calculator program for students to practice arithmetic
operations. The calculator
should allow users to perform addition, subtraction, multiplication, division, and power
on two
numbers entered via user input. Each operation will be executed using separate
functions




Code:
#include <iostream>
#include <cmath>
using namespace std;
double add(double a, double b);
double subtract(double a, double b);
double multiply(double a, double b);
double divide(double a, double b);
double power(double base, double exponent);
int main() {
double num1, num2;
char operation;

,BS(IT),SEMESTER #01, CP#LAB 05
NAME :UROOJ ASGHAR KHAN
ENROLLMENT # 02-135242-006

cout << "Basic Calculator" << endl;
cout << "Enter numbe 01: ";
cin >> num1;
cout << "Enter numbe 02: ";
cin >> num2;
cout << "Choose an operation (+, -, *, /, ^): ";
cin >> operation;
switch (operation) {
case '+':
cout << "Result: " << add(num1, num2) << endl;
break;
case '-':
cout << "Result: " << subtract(num1, num2) << endl;
break;
case '*':
cout << "Result: " << multiply(num1, num2) << endl;
break;
case '/':
if (num2 != 0) {
cout << "Result: " << divide(num1, num2) << endl;
} else {
cout << "Division by zero is not calculated" << endl;
}
break;
case '^':

, BS(IT),SEMESTER #01, CP#LAB 05
NAME :UROOJ ASGHAR KHAN
ENROLLMENT # 02-135242-006

cout << "Result: " << power(num1, num2) << endl;
break;
default:
cout << "Invalid operation!" << endl;
}
return 0;
}
double add(double a, double b) {
return a + b;
}


double subtract(double a, double b) {
return a - b;
}


double multiply(double a, double b) {
return a * b;
}


double divide(double a, double b) {
return a / b;
}


double power(double base, double exponent) {
return pow(base, exponent);

Written for

Course

Document information

Uploaded on
January 18, 2026
Number of pages
21
Written in
2024/2025
Type
Exam (elaborations)
Contains
Questions & answers

Subjects

$8.99
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
uroojkhan1

Also available in package deal

Get to know the seller

Seller avatar
uroojkhan1 Bahria university
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
3 months
Number of followers
0
Documents
13
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions