0% found this document useful (0 votes)
10 views10 pages

RAFIA ZUBAIR bsf23005107

1) The document is an assignment submitted by Rafia Zubair to her professor Dr. Muhammad Anwar. It includes 5 programs written in C++ to solve various problems around maximum number calculation, factorials, counting currency notes, calculating electricity bills, and designing an ATM interface. 2) Each program is presented with the source code and corresponding output. 3) The assignment demonstrates Rafia Zubair's understanding of basic programming concepts like conditional statements, loops, functions in C++.

Uploaded by

itxgametimes
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)
10 views10 pages

RAFIA ZUBAIR bsf23005107

1) The document is an assignment submitted by Rafia Zubair to her professor Dr. Muhammad Anwar. It includes 5 programs written in C++ to solve various problems around maximum number calculation, factorials, counting currency notes, calculating electricity bills, and designing an ATM interface. 2) Each program is presented with the source code and corresponding output. 3) The assignment demonstrates Rafia Zubair's understanding of basic programming concepts like conditional statements, loops, functions in C++.

Uploaded by

itxgametimes
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/ 10

UNIVERSITY OF EDUCATION LAHORE

(Faisalabad campus)

Assignment # 1

Subject: Programming Fundamental

Submitted to: Dr. Muhammad Anwar


Submitted by: Rafia Zubair
Roll No: bsf23005107

Program: BS Computer Science

Semester: First

Section: (A)

Session: 2023-2027

Shift: Morning
PROGRAMS

 Program # 1: Write a program to that can take three


numbers as input from user and find maximum among them.

#include<iostream>
using namespace std;
int main()
{
int num1,num2,num3;
cout<< "Enter Num 1";
cin>> num1;
cout<< "Enter Num 2";
cin>> num2;
cout<< "Enter Num 3";
cin>> num3;

if( num1>num2&&num1>num3)
{
cout<< "Num 1 is Maximum";

}
else if( num2>num1&&num2>num3)

{
cout<<"Num 2 is Maximum";
}
else
cout<< "Num 3 is Maximum"<<endl;
cout<< "RAFIA ZUBAIR"<<endl;

}
OUTPUT:

 Program # 2: Write a program which ask user to enter a


positive integer and then calculate its factorial.

#include <iostream>
using namespace std;
int main()
{
int num;
cout<<"Enter a positive integer:";
cin>> num;
int factorial = 1;
for(int i = 1;i <=num; i++)

{
factorial*=i;
}
cout<<"The factorial of " << num<<" is " <<factorial<<endl;
cout<<"RAFIA ZUBAIR "<<endl;
}
OUTPUT:

 Program # 3: Write a program to count total number of


currency notes of 5000, 1000, 500, 100, 50, 20 and 10 in a
given amount.

#include <iostream>
using namespace std;

int main()
{
int amount;
cout << "Enter the amount: ";
cin >> amount;
int count5000 = 0, count1000 = 0, count500 = 0, count100 = 0, count50 = 0,
count20 = 0, count10 = 0;
if (amount >= 5000)
{
count5000 = amount / 5000;
amount = amount % 5000;
}
if (amount >= 1000)
{
count1000 = amount / 1000;
amount = amount % 1000;
}

if (amount >= 500)


{
count500 = amount / 500;
amount = amount % 500;
}
if (amount >= 100) {
count100 = amount / 100;
amount = amount % 100;
}

if (amount >= 50)


{
count50 = amount / 50;
amount = amount % 50;
}
if (amount >= 20)
{
count20 = amount / 20;
amount = amount % 20;
}
if (amount >= 10)
{
amount = amount % 10;
}
cout << "Number of 5000 notes: " << count5000 << endl;
cout << "Number of 1000 notes: " << count1000 << endl;
cout << "Number of 500 notes: " << count500 << endl;
cout << "Number of 100 notes: " << count100 << endl;
cout << "Number of 50 notes: " << count50 << endl;
cout << "Number of 20 notes: " << count20 << endl;
cout << "Number of 10 notes: " << count10 << endl;
cout<< "RAFIA ZUBAIR "<<endl;
}
OUTPUT:

 Program # 4: Write a program to input electricity bill


consumed and calculate total electricity bill according to
given conditions:
 If no. of units up to 100, bill will be charged at the rate of Rs. 5 per unit
 If no. of units up to 200, bill will be charged at the rate of Rs. 10 per unit
 If no. of units above 200, bill will be charged at the rate of Rs. 20 per unit

#include <iostream>
using namespace std;
int main()
{
int units;
int TotalBill=0;
cout<<"Enter number of units:";
cin>>units;
if(units<=100)
{
TotalBill=units*5;
}
else if(units<=200)
{
TotalBill=units*10;
}
else
{
TotalBill=units*20;
}
cout<<"Total electricity Bill is Rs."<< TotalBill<<endl;
cout<<"RAFIA ZUBAIR"<<endl;
return 0;

OUTPUT:

 Program # 5: Write a program to design ATM interface


to perform following transactions. You may initialize balance
with zero. After each transaction, program should ask user
to perform another transaction. Based on input(y/n)
program either redirects to main interface or exist.
 Press B to check account balance
 Press D to cash deposit
 Press W to cash withdraw

#include<iostream>
using namespace std;
int main()
{
char choice;
double balance = 0.0;

do
{
cout << "Welcome to the ATM Interface" << endl;
cout << "Press B to check account balance" << endl;
cout << "Press D to cash deposit" << endl;
cout << "Press W to cash withdraw" << endl;
cout << "Enter your choice: ";
cin >> choice;

switch (choice)
{
case 'B':
case 'b':
cout << "Account Balance: Rs. " << balance << endl;
break;

case 'D':
case 'd':
double deposit;
cout << "Enter the amount to deposit: Rs. ";
cin >> deposit;
if (deposit > 0)
{
balance += deposit;
cout << "Deposited Rs. " << deposit << " successfully." << endl;
}
else
{
cout << "Invalid deposit amount. Please enter a positive amount."
<< endl;
}
break;

case 'W':
case 'w':
double withdraw;
cout << "Enter the amount to withdraw: Rs. ";
cin >> withdraw;
if (withdraw > 0 && withdraw <= balance)
{
balance -= withdraw;
cout << "Withdrawn Rs. " << withdraw << " successfully." << endl;
}
else if (withdraw > balance)
{
cout << "Insufficient balance for withdrawal." << endl;
}
else
{
cout << "Invalid withdrawal amount. Please enter a positive
amount." << endl;
}
break;

default:
cout << "Invalid choice. Please select a valid option." << endl;
}
char continueChoice;
cout << "Do you want to perform another transaction? (y/n): ";
cin >> continueChoice;

if (continueChoice != 'y' && continueChoice != 'Y')


{
cout << "Thank you for using the ATM. Have a nice day!" << endl;
cout << "RAFIA ZUBAIR" << endl;
break;
}
}
while (true);
return 0;
}

OUTPUT:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy