PF Assignment Muhammad Ali Huzaifa(242690)
PF Assignment Muhammad Ali Huzaifa(242690)
[Assignment#01]
[Muhammad Ali Huzaifa]
[242690]
[Programming Fundamentals]
[Dr. Faheem Ullah]
[October 18, 2024]
Question 1
Fibonacci series
#include<iostream>
int main(){
f3=f2+f1;
cout<<f3<<", ";
return 0;
}
[2]
Question 2
BMI Calculator
#include<iostream>
double w, h, s, b; //w for weight, h for height, s for height squared, b for BMI
cin>>w;
cin>>h;
}
[3]
else if(b>=30){
else{
cout<<"Invalid Info"<<endl;
int main(){
char choice;
do{
bmiCal();
while(choice != 'y' && choice != 'n' && choice != 'Y' && choice != 'N'){
cin>>choice;
return 0;
[4]
Question 3
Park Ticket Price
#include<iostream>
#include<fstream>
using namespace std;
int main() {
int age;
int ticketprice;
char choice;
do {
// Ask for visitor's age
cout << "Enter age of the visitor: ";
cin >> age;
ticketprice = 10;
break;
case 15 ... 18:
ticketprice = 15;
break;
default:
ticketprice = 20;
break;
}
// Write to file
outfile << "Visitor's age: " << age << ", Ticket price: Rs. " << ticketprice
<< endl;
outfile.close(); // Close file
} while (choice == 'y' || choice == 'Y'); // Continue if user enters 'y' or 'Y'
return 0;
}
[6]
Question 4
Gross Pay
#include<iostream>
void grossPay(){
t=h+i;
cin>>t;
cin>>r; // Calculate gross pay: Regular pay for first 40 hours + 1.5x
pay for overtime
int main(){
char choice;
do{
cin>>choice;
while(choice != 'y' && choice != 'n' && choice != 'Y' && choice != 'N'){
cin>>choice;
return 0;
Question 5
Car Loan
#include<iostream>
void monthlyInst(){
double m; //months
cin>>p;
cin>>d;
if(m<=12){
i=0.10;
i=0.15;
i=0.20;
i=0.25;
i=0.30;
else{
int main(){
char choice;
do{
cin>>choice;
while(choice != 'y' && choice != 'n' && choice != 'Y' && choice != 'N'){
cin>>choice;
return 0;
}
[10]
Question 6
Patterns of Stars
A.
#include<iostream>
cout<<"*";
return 0;
B. #include<iostream>
using namespace std;
int main() {
cout << endl; // Move to the next line after printing each row
}
return 0;
C.
#include<iostream>
int main(){
cout<<" ";
else{
cout << endl; // Move to the next line after printing each row
return 0;
}
[12]
D.
#include<iostream>
cout << endl; } // Move to the next line after printing each row
return 0;
E.
#include<iostream>
int main(){
cout<<" ";
cout<<endl;
return 0;
F.
#include<iostream>
cout<<" ";
return 0;
G.
#include<iostream>
cout<<" ";
[14]
cout<<endl;
cout<<" ";
return 0;