SlideShare a Scribd company logo
1 of 2
Download to read offline
Bahria University
Lahore Campus
Department of Computer Science
Computer Programming (CSC-113)
Assignment 01 (There will be a test in the start of lecture on 21OCT-19)
Max Marks: 50 Deadline: 18-Oct-19 (Friday) 3pm
Question # 1 [4 marks]
Write down the E notation for each of the following expressions in the given manner?
Expression E-Notation
A) 3.287 × 106
B) -978.65 × 1012
C) 7.65491 × 10-3
D) -58710.23 × 10-4
Question # 2 [6 marks]
Distance per Tank of Gas
A car with a 20-gallon gas tank averages 21.5 miles per gallon when driven in town and 26.8 miles
per gallon when driven on the highway. Write a program that calculates and displays the distance
the car can travel on one tank of gas when driven in town and when driven on the highway.
Hint: The following formula can be used to calculate the distance:
Distance = Number of Gallons × Average Miles per Gallon
Question # 3 [4+6 marks]
(A) Type the above code and note down the output of your program.
(B) Do the same work using const variables of appropriate data type, instead of #define.
#include <iostream>
using namespace std;
#define WHO "Columbus"
#define DID "sailed"
#define WHAT "the ocean blue."
int main()
{
const int WHEN = 1492;
cout << "In " << WHEN << " " << WHO << " "
<< DID << " " << WHAT << endl;
return 0;
}
Question # 4 [10 marks]
Note down (in your own handwriting) the C++ Library function that returns each of the following:
01. The cosine of an angle. 02. The sine of an angle.
03. The tangent of an angle. 04. The exponential function of a number.
05. The remainder of a floating point division. 06. The natural logarithm of a number.
07. The base-10 logarithm of a number. 08. The value of a number raised to a power.
09. The square root of a number.
Also note down the header file that is required to be included for above functions.
Question # 5 [10 marks]
Pizza Pi
Joe’s Pizza Palace needs a program to calculate the number of slices a pizza of any size can be
divided into. The program should perform the following steps:
A) Ask the user for the diameter of the pizza in inches.
B) Calculate the number of slices that may be taken from a pizza of that size.
C) Display a message telling the number of slices.
To calculate the number of slices that may be taken from the pizza, use the following facts:
• Each slice should have an area of 14.125 inches.
• To calculate the number of slices, simply divide the area of the pizza by 14.125.
• The area of the pizza is calculated with this formula:
NOTE: Area = πr2. π is the Greek letter pi. 3.14159 can be used as its value. The variable r is the
radius of the pizza. Divide the diameter by 2 to get the radius. Use a named constant for pi.
Question # 6 [10 marks]
Word Game
Write a program that plays a word game with the user. The program should ask the user to enter
the following:
• His or her name
• His or her age
• The name of a city
• The name of a college
• A profession
• A type of animal
• A pet’s name
After the user has entered these items, the program should display the following story, inserting
the user’s input into the appropriate locations:
There once was a person named NAME who lived in CITY. At the age of AGE, NAME went to
college at COLLEGE. NAME graduated and went to work as a PROFESSION. Then, NAME
adopted a(n) ANIMAL named PETNAME. They both lived happily ever after!
Submit handwritten solution of this assignment before the deadline given in the title.

More Related Content

Similar to Bahria University computer programming assignment

Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxtiffanyd4
 
Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Mohamed El Desouki
 
C programming assignment presentation file
C programming assignment presentation fileC programming assignment presentation file
C programming assignment presentation filesantoshkumarhpu
 
Comp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source codeComp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source codepradesigali1
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxAASTHA76
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2Animesh Chaturvedi
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy BookAbir Hossain
 
M150 A Fall2010 T01
M150 A Fall2010 T01M150 A Fall2010 T01
M150 A Fall2010 T01abdalodainat
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEWshyamuopeight
 
1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docxoswald1horne84988
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 solIIUM
 
Year 2 dsa c++ exercises on user defined functions
Year 2 dsa  c++ exercises on user defined functionsYear 2 dsa  c++ exercises on user defined functions
Year 2 dsa c++ exercises on user defined functionsErnesteNtezirizaza
 
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18HIMANSHU .
 

Similar to Bahria University computer programming assignment (20)

Chapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docxChapter 8Exercise1.Design an application that accept.docx
Chapter 8Exercise1.Design an application that accept.docx
 
Java Practice Set
Java Practice SetJava Practice Set
Java Practice Set
 
Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++Basic Programming concepts - Programming with C++
Basic Programming concepts - Programming with C++
 
C programming assignment presentation file
C programming assignment presentation fileC programming assignment presentation file
C programming assignment presentation file
 
Comp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source codeComp 122 lab 3 lab report and source code
Comp 122 lab 3 lab report and source code
 
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docxBottom of FormCreate your own FunctionFunctionsFor eac.docx
Bottom of FormCreate your own FunctionFunctionsFor eac.docx
 
A01
A01A01
A01
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
 
An Introduction To Python - Strings & I/O
An Introduction To Python - Strings & I/OAn Introduction To Python - Strings & I/O
An Introduction To Python - Strings & I/O
 
M150 A Fall2010 T01
M150 A Fall2010 T01M150 A Fall2010 T01
M150 A Fall2010 T01
 
COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
1 ECE 175 Computer Programming for Engineering Applica.docx
1  ECE 175 Computer Programming for Engineering Applica.docx1  ECE 175 Computer Programming for Engineering Applica.docx
1 ECE 175 Computer Programming for Engineering Applica.docx
 
I PUC CS Lab_programs
I PUC CS Lab_programsI PUC CS Lab_programs
I PUC CS Lab_programs
 
Mid term sem 2 1415 sol
Mid term sem 2 1415 solMid term sem 2 1415 sol
Mid term sem 2 1415 sol
 
Year 2 dsa c++ exercises on user defined functions
Year 2 dsa  c++ exercises on user defined functionsYear 2 dsa  c++ exercises on user defined functions
Year 2 dsa c++ exercises on user defined functions
 
Mmt 001
Mmt 001Mmt 001
Mmt 001
 
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
COMPUTER SCIENCE INVESTIGATORY PROJECT 2017-18
 
QUIZ 1.pptx
QUIZ 1.pptxQUIZ 1.pptx
QUIZ 1.pptx
 
1.2 matlab numerical data
1.2  matlab numerical data1.2  matlab numerical data
1.2 matlab numerical data
 

More from Abdul Wahab Raza

Understanding Groups and Teams
Understanding Groups and Teams Understanding Groups and Teams
Understanding Groups and Teams Abdul Wahab Raza
 
Human Resources and Management
Human Resources and ManagementHuman Resources and Management
Human Resources and ManagementAbdul Wahab Raza
 
Communication and information Technology
Communication and information TechnologyCommunication and information Technology
Communication and information TechnologyAbdul Wahab Raza
 
Organizational Structure and Design
Organizational Structure and DesignOrganizational Structure and Design
Organizational Structure and DesignAbdul Wahab Raza
 
Decision Making in Managerial job
Decision Making in Managerial jobDecision Making in Managerial job
Decision Making in Managerial jobAbdul Wahab Raza
 
Social Responsibilities and Managerial Ethics.
Social Responsibilities and Managerial Ethics.Social Responsibilities and Managerial Ethics.
Social Responsibilities and Managerial Ethics.Abdul Wahab Raza
 
Management in Global environment
Management in Global environmentManagement in Global environment
Management in Global environmentAbdul Wahab Raza
 
Organizational culture and its enviroment
Organizational culture and its enviromentOrganizational culture and its enviroment
Organizational culture and its enviromentAbdul Wahab Raza
 
Introduction to Management and organization
Introduction to Management and organizationIntroduction to Management and organization
Introduction to Management and organizationAbdul Wahab Raza
 
Body language during presentation
Body language during presentationBody language during presentation
Body language during presentationAbdul Wahab Raza
 
Introduction to managers and organization
Introduction to managers and organizationIntroduction to managers and organization
Introduction to managers and organizationAbdul Wahab Raza
 
Parallel circuit of physics
Parallel circuit of physicsParallel circuit of physics
Parallel circuit of physicsAbdul Wahab Raza
 

More from Abdul Wahab Raza (20)

Motivating Employees
Motivating EmployeesMotivating Employees
Motivating Employees
 
Understanding Groups and Teams
Understanding Groups and Teams Understanding Groups and Teams
Understanding Groups and Teams
 
Human Resources and Management
Human Resources and ManagementHuman Resources and Management
Human Resources and Management
 
Communication and information Technology
Communication and information TechnologyCommunication and information Technology
Communication and information Technology
 
Organizational Structure and Design
Organizational Structure and DesignOrganizational Structure and Design
Organizational Structure and Design
 
Strategic Management
Strategic ManagementStrategic Management
Strategic Management
 
Foundations of planning
Foundations of planningFoundations of planning
Foundations of planning
 
foundation of Behavior
foundation of Behaviorfoundation of Behavior
foundation of Behavior
 
Decision Making in Managerial job
Decision Making in Managerial jobDecision Making in Managerial job
Decision Making in Managerial job
 
Social Responsibilities and Managerial Ethics.
Social Responsibilities and Managerial Ethics.Social Responsibilities and Managerial Ethics.
Social Responsibilities and Managerial Ethics.
 
Management in Global environment
Management in Global environmentManagement in Global environment
Management in Global environment
 
Organizational culture and its enviroment
Organizational culture and its enviromentOrganizational culture and its enviroment
Organizational culture and its enviroment
 
Management History
Management HistoryManagement History
Management History
 
Introduction to Management and organization
Introduction to Management and organizationIntroduction to Management and organization
Introduction to Management and organization
 
Body language during presentation
Body language during presentationBody language during presentation
Body language during presentation
 
Introduction to managers and organization
Introduction to managers and organizationIntroduction to managers and organization
Introduction to managers and organization
 
Drugs and its impact
Drugs and its impactDrugs and its impact
Drugs and its impact
 
Series circuit
Series circuitSeries circuit
Series circuit
 
Introduction of multisim
Introduction of multisimIntroduction of multisim
Introduction of multisim
 
Parallel circuit of physics
Parallel circuit of physicsParallel circuit of physics
Parallel circuit of physics
 

Recently uploaded

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Intelisync
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...gurkirankumar98700
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideChristina Lin
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...Christina Lin
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software DevelopersVinodh Ram
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...MyIntelliSource, Inc.
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Recently uploaded (20)

Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)Introduction to Decentralized Applications (dApps)
Introduction to Decentralized Applications (dApps)
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
(Genuine) Escort Service Lucknow | Starting ₹,5K To @25k with A/C 🧑🏽‍❤️‍🧑🏻 89...
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop SlideBuilding Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
Building Real-Time Data Pipelines: Stream & Batch Processing workshop Slide
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
ODSC - Batch to Stream workshop - integration of Apache Spark, Cassandra, Pos...
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Professional Resume Template for Software Developers
Professional Resume Template for Software DevelopersProfessional Resume Template for Software Developers
Professional Resume Template for Software Developers
 
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
Try MyIntelliAccount Cloud Accounting Software As A Service Solution Risk Fre...
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 

Bahria University computer programming assignment

  • 1. Bahria University Lahore Campus Department of Computer Science Computer Programming (CSC-113) Assignment 01 (There will be a test in the start of lecture on 21OCT-19) Max Marks: 50 Deadline: 18-Oct-19 (Friday) 3pm Question # 1 [4 marks] Write down the E notation for each of the following expressions in the given manner? Expression E-Notation A) 3.287 × 106 B) -978.65 × 1012 C) 7.65491 × 10-3 D) -58710.23 × 10-4 Question # 2 [6 marks] Distance per Tank of Gas A car with a 20-gallon gas tank averages 21.5 miles per gallon when driven in town and 26.8 miles per gallon when driven on the highway. Write a program that calculates and displays the distance the car can travel on one tank of gas when driven in town and when driven on the highway. Hint: The following formula can be used to calculate the distance: Distance = Number of Gallons × Average Miles per Gallon Question # 3 [4+6 marks] (A) Type the above code and note down the output of your program. (B) Do the same work using const variables of appropriate data type, instead of #define. #include <iostream> using namespace std; #define WHO "Columbus" #define DID "sailed" #define WHAT "the ocean blue." int main() { const int WHEN = 1492; cout << "In " << WHEN << " " << WHO << " " << DID << " " << WHAT << endl; return 0; }
  • 2. Question # 4 [10 marks] Note down (in your own handwriting) the C++ Library function that returns each of the following: 01. The cosine of an angle. 02. The sine of an angle. 03. The tangent of an angle. 04. The exponential function of a number. 05. The remainder of a floating point division. 06. The natural logarithm of a number. 07. The base-10 logarithm of a number. 08. The value of a number raised to a power. 09. The square root of a number. Also note down the header file that is required to be included for above functions. Question # 5 [10 marks] Pizza Pi Joe’s Pizza Palace needs a program to calculate the number of slices a pizza of any size can be divided into. The program should perform the following steps: A) Ask the user for the diameter of the pizza in inches. B) Calculate the number of slices that may be taken from a pizza of that size. C) Display a message telling the number of slices. To calculate the number of slices that may be taken from the pizza, use the following facts: • Each slice should have an area of 14.125 inches. • To calculate the number of slices, simply divide the area of the pizza by 14.125. • The area of the pizza is calculated with this formula: NOTE: Area = πr2. π is the Greek letter pi. 3.14159 can be used as its value. The variable r is the radius of the pizza. Divide the diameter by 2 to get the radius. Use a named constant for pi. Question # 6 [10 marks] Word Game Write a program that plays a word game with the user. The program should ask the user to enter the following: • His or her name • His or her age • The name of a city • The name of a college • A profession • A type of animal • A pet’s name After the user has entered these items, the program should display the following story, inserting the user’s input into the appropriate locations: There once was a person named NAME who lived in CITY. At the age of AGE, NAME went to college at COLLEGE. NAME graduated and went to work as a PROFESSION. Then, NAME adopted a(n) ANIMAL named PETNAME. They both lived happily ever after! Submit handwritten solution of this assignment before the deadline given in the title.