0% found this document useful (0 votes)
5 views5 pages

Na Me Jawad Ahmad Section EE-1B Roll No 24f-6024

The document outlines five programming tasks in C++ involving user input and output. Tasks include creating personalized greetings, converting temperatures from Fahrenheit to Celsius, displaying a table of student names and grades, converting rupees to dollars, and calculating the average of three integers. Each task is accompanied by sample code demonstrating the required functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views5 pages

Na Me Jawad Ahmad Section EE-1B Roll No 24f-6024

The document outlines five programming tasks in C++ involving user input and output. Tasks include creating personalized greetings, converting temperatures from Fahrenheit to Celsius, displaying a table of student names and grades, converting rupees to dollars, and calculating the average of three integers. Each task is accompanied by sample code demonstrating the required functionality.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Na

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>

using namespace std;

int main() {

string name;
int age;

cout << "Please enter your name: ";


cin >> name;

cout << "Please enter your age: ";


cin >> 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 << "Enter temperature in Fahrenheit: ";


cin >> fahrenheit;

float celsius = (fahrenheit - 32) / 1.8;

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>

using namespace std;

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>

using namespace std;

int main() {
int value1, value2, value3;
double average;

cout << "Enter 3 integer values:" << endl;

cin >> value1;


cin >> value2;
cin >> value3;

average = (value1 + value2 + value3) / 3.0;


cout << "The average is: " << average << endl;

return 0;
}

You might also like