Na Me Jawad Ahmad Section EE-1B Roll No 24f-6024
Na Me Jawad Ahmad Section EE-1B Roll No 24f-6024
me = Jawad Ahmad
Section= EE-1B
Roll no = 24f-6024
TASK 1
Write a program that asks the user for their name and age, store the information
in variables using cin and print a personalized greeting message using cout.
CODE
#include <iostream>
int main() {
string name;
int age;
cout << "Happy day to an amazing " << age << " year old, " <<
name << "!" << endl;
return 0;
}
TASK 2
Write a program in C++ to read temperature in Fahrenheit. Convert the
temperature to Celsius degrees by using the formula
C = 5/9 (F-32)
CODE
#include <iostream>
using namespace std;
int main() {
float fahrenheit;
cout << fahrenheit << "°F is equal to " << celsius << "°C" <<
::endl;
return 0;
}
TAKE 3
Create a program that displays a table of student names and grades.
(Hint: Format the output using setw and setprecision to create a well-organized
table.)
CODE
#include <iostream>
#include <iomanip>
int main() {
cout << left << setw(15) << "Student Name" << "Grade" <<
endl;
cout << "-------------------------------" << endl;
cout << left << setw(15) << "Ali" << 'A' << endl;
cout << left << setw(15) << "Ayesha" << 'B' << endl;
cout << left << setw(15) << "Ahmed" << 'A' << endl;
return 0;
}
TASK 4
Write a program that converts a given amount in rupees to dollars.
CODE
#include <iostream>
using namespace std;
int main() {
float rupees;
const float EXCHANGE_RATE = 0.0036;
cout << "Enter amount in Rupees: ";
cin >> rupees;
float dollars = rupees * EXCHANGE_RATE;
cout << rupees << " PKR = " << dollars << " USD" << endl;
return 0;}
TASK 5
Write a program that calculates the average of a set of integer values and display
the result with appropriate precision.
CODE
#include <iostream>
int main() {
int value1, value2, value3;
double average;
return 0;
}