Professional Documents
Culture Documents
(Faisalabad campus)
Assignment # 1
Semester: First
Section: (A)
Session: 2023-2027
Shift: Morning
PROGRAMS
#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:
#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:
#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;
}
#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:
#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;
OUTPUT: