SlideShare a Scribd company logo
1 of 5
Practice questions:
1. Write a program in C++ to store registration of 100 students and their 7
courses. Calculate class average of each of course and display.
2. (Credit Limit Calculator) Develop a C program that will determine if a
department store customer has exceeded the credit limit on a charge account.
For each customer, the following facts are available:
a. Account number
b. Balance at the beginning of the month
c. Total of all items charged by this customer this month
d. Total of all credits applied to this customer's account this month
e. Allowed credit limit
The program should input each fact, calculate the new balance (= beginning
balance + charges – credits), and determine whether the new balance
exceeds the customer's credit limit. For those customers whose credit limit
is exceeded, the program should display the customer's account number,
credit limit, new balance and the message “Credit limit exceeded.” Here is
a sample input/output dialog
3. One large chemical company pays its salespeople on a commission basis.
The salespeople receive $200 per week plus 9% of their gross sales for that
week. For example, a salesperson who sells $5000 worth of chemicals in a
week receives $200 plus 9% of $5000, or a total of $650. Develop a program
that will input each salesperson’s gross sales for last week and will calculate
and display that salesperson’s earnings. Process one salesperson's figures at
a time. Here is a sample input/output dialog:
4. The simple interest on a loan is calculated by the formula:
Interest = principal * rate * days / 365;
The preceding formula assumes that rate is the annual interest rate, and therefore
includes the division by 365 (days). Develop a program that will input principal,
rate and days for several loans, and will calculate and display the simple interest
for each loan, using the preceding formula.
Here is a sample input/output dialog:
5. Write a program that finds the smallest of several integers (without using
array). Assume that the first value read specifies the number of values
remaining.
6. One interesting application of computers is drawing graphs and bar charts
(sometimes called “histograms”). Write a program that reads five numbers
(each between 1 and 30). For each number read, your program should print
a line containing that number of adjacent asterisks. For example, if your
program reads the number seven, it should print *******.
7. An online retailer sells five different products whose retail prices are shown
in the following table:
Write a program that reads a series of pairs of numbers as follows:
a) Product number
b) Quantity sold for one day
Your program should use a switch statement to help determine the retail price
for each product.
Your program should calculate and display the total retail value of all products
sold last week.
8. (CalculatingWeeklyPay) A company pays its employees as managers (who
receive a fixed weekly salary), hourly workers (who receive a fixed hourly
wage for up to the first 40 hours they work and “time-and-a-half”—i.e., 1.5
times their hourly wage—for overtime hours worked), commission workers
(who receive $250 plus 5.7% of their gross weekly sales), or pieceworkers
(who receive a fixed amount of money for each of the items they produce—
each pieceworker in this company works on only one type of item). Write a
program to compute the weekly pay for each employee. You do not know
the number of employees in advance. Each type of employee has its own
pay code: Managers have paycode 1, hourly workers have code 2,
commission workers have code 3 and pieceworkers have code 4. Use a
switch to compute each employee’s pay based on that employee’s paycode.
Within the switch, prompt the user (i.e., the payroll clerk) to enter the
appropriate facts your program needs to calculate each employee’s pay
based on that employee’s paycode.
9. Write a program that prints the following diamond shape
10. (Parking Charges)A parking garagecharges a $2.00minimum fee to parkforup to three hours
and an additional$0.50 perhourfor each hour or part thereofoverthree hours. The maximum
charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24
hours at a time. Write a programthat will calculate and print the parking charges for each of
three customers who parked their cars in this garage yesterday. You should enter the hours
parked foreach customer.Yourprogramshould print theresults in a tabularformat,and should
calculate and print the total of yesterday's receipts. The program should use the function
calculateCharges to determine the charge for each customer. Your outputs should appear in the
following format:
11. (Hypotenuse Calculations) Define a function called hypotenuse that
calculates the length of the hypotenuse of a right triangle when the other
two sides are given. The function should take two arguments of type
double and return the hypotenuse as a double.
12. (Square of Asterisks) Write a function that displays a solid square of
asterisks whose side is specified in integer parameter side. For example, if
side is 4, the function displays:
13. (Displaying a Square of Any Character) Modify the function created in
Exercise 5.19 to form the square out of whatever character is contained in
character parameter fillCharacter. Thus if side is 5 and fillCharacter is “#”,
then this function should print:
14. (Separating Digits) Write program segments that accomplish each of the
following:
a. Calculate the integer part of the quotient when integer a is divided by
integer b.
b. Calculate the integer remainder when integer a is divided by integer b.
c. Use the program pieces developed in a) and b) to write a function that
inputs an integer between 1 and 32767 and prints it as a series of digits,
with two spaces between each digit.
For example, the integer 4562 should be printed as:
15. Given the following structure and variable definitions,
struct customer {
char lastName[ 15 ];
char firstName[ 15 ];
unsigned int customerNumber;
struct {
char phoneNumber[ 11 ];
char address[ 50 ];
char city[ 15 ];
char state[ 3 ];
char zipCode[ 6 ];
} personal;
} customerRecord, *customerPtr;
customerPtr = &customerRecord
Write an expression that can be used to access the structure members in each of
the following parts:
a. Member lastName of structure customerRecord.
b. Member lastName of the structure pointed to by customerPtr.
c. Member firstName of structure customerRecord.
d. Member firstName of the structure pointed to by customerPtr.
e. Member customerNumber of structure customerRecord.
f. Member customerNumber of the structure pointed to by customerPtr.
g. Member phoneNumber of member personal of structure
customerRecord.
h. Member phoneNumber of member personal of the structure pointed to
by customerPtr.
i. Member address of member personal of structure customerRecord.
j. Member address of member personal of the structure pointed to by
customerPtr.
k. Member city of member personal of structure customerRecord.
l. Member city of member personal of the structure pointed to by
customerPtr.
m. Member state of member personal of structure customerRecord.
n. Member state of member personal of the structure pointed to by
customerPtr.
o. Member zipCode of member personal of structure customerRecord.
p. Member zipCode of member personal of the structure pointed to by
customerPtr.
16. Write statements that accomplish each of the following. Assume that the
structure
struct person {
char lastName[ 15 ];
char firstName[ 15 ];
char age[ 4 ];
};
has been defined and that the file is already open for writing.
a. Initialize the file "nameage.dat" so that there are 100 records with
lastName = "unassigned", firstname = "" and age = "0".
b. Input 10 last names, first names and ages, and write them to the file.
c. Update a record; if there’s no information in the record, tell the user
"No info".
d. Delete a record that has information by reinitializing that particular
record.

More Related Content

Similar to Programming - C++

COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEWshyamuopeight
 
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
 
List of programs to practice for ICSE
List of programs to practice for ICSEList of programs to practice for ICSE
List of programs to practice for ICSEMokshya Priyadarshee
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchartfika sweety
 
Part I (Short Answer)1. In Java, what are the three different w.docx
Part I (Short Answer)1. In Java, what are the three different w.docxPart I (Short Answer)1. In Java, what are the three different w.docx
Part I (Short Answer)1. In Java, what are the three different w.docxherbertwilson5999
 
MortgageCalculator.javaMortgageCalculator.java  The mortga.docx
MortgageCalculator.javaMortgageCalculator.java  The mortga.docxMortgageCalculator.javaMortgageCalculator.java  The mortga.docx
MortgageCalculator.javaMortgageCalculator.java  The mortga.docxgilpinleeanna
 
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
 
By Analyzing and Utilizing Jean Watson theory of caring, creat
By Analyzing and Utilizing Jean Watson theory of caring, creatBy Analyzing and Utilizing Jean Watson theory of caring, creat
By Analyzing and Utilizing Jean Watson theory of caring, creatTawnaDelatorrejs
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy BookAbir Hossain
 
Itco 620 unit 5 project
Itco 620 unit 5 projectItco 620 unit 5 project
Itco 620 unit 5 projectcomp274
 
EC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab ManualEC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab Manualtamil arasan
 
CSCE 1030 Project 2 Due 1159 PM on Sunday, March 28, 2021
CSCE 1030 Project 2 Due 1159 PM on Sunday, March 28, 2021CSCE 1030 Project 2 Due 1159 PM on Sunday, March 28, 2021
CSCE 1030 Project 2 Due 1159 PM on Sunday, March 28, 2021MargenePurnell14
 
Copying number ranges in SAP FICO ECC
Copying number ranges  in SAP FICO ECCCopying number ranges  in SAP FICO ECC
Copying number ranges in SAP FICO ECCSrinivas Rao
 
Statement of Operations and Financial StatementsSubmit written r.docx
Statement of Operations and Financial StatementsSubmit written r.docxStatement of Operations and Financial StatementsSubmit written r.docx
Statement of Operations and Financial StatementsSubmit written r.docxwhitneyleman54422
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2Animesh Chaturvedi
 
Railway ticket Simple Program
Railway ticket Simple ProgramRailway ticket Simple Program
Railway ticket Simple ProgramElla Marie Wico
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxAASTHA76
 
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docxStudent Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docxemelyvalg9
 

Similar to Programming - C++ (20)

COMP 122 Entire Course NEW
COMP 122 Entire Course NEWCOMP 122 Entire Course NEW
COMP 122 Entire Course NEW
 
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
 
List of programs to practice for ICSE
List of programs to practice for ICSEList of programs to practice for ICSE
List of programs to practice for ICSE
 
Pseudocode algorithim flowchart
Pseudocode algorithim flowchartPseudocode algorithim flowchart
Pseudocode algorithim flowchart
 
Part I (Short Answer)1. In Java, what are the three different w.docx
Part I (Short Answer)1. In Java, what are the three different w.docxPart I (Short Answer)1. In Java, what are the three different w.docx
Part I (Short Answer)1. In Java, what are the three different w.docx
 
MortgageCalculator.javaMortgageCalculator.java  The mortga.docx
MortgageCalculator.javaMortgageCalculator.java  The mortga.docxMortgageCalculator.javaMortgageCalculator.java  The mortga.docx
MortgageCalculator.javaMortgageCalculator.java  The mortga.docx
 
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
 
By Analyzing and Utilizing Jean Watson theory of caring, creat
By Analyzing and Utilizing Jean Watson theory of caring, creatBy Analyzing and Utilizing Jean Watson theory of caring, creat
By Analyzing and Utilizing Jean Watson theory of caring, creat
 
Important C program of Balagurusamy Book
Important C program of Balagurusamy BookImportant C program of Balagurusamy Book
Important C program of Balagurusamy Book
 
Itco 620 unit 5 project
Itco 620 unit 5 projectItco 620 unit 5 project
Itco 620 unit 5 project
 
EC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab ManualEC6612 VLSI Design Lab Manual
EC6612 VLSI Design Lab Manual
 
CSCE 1030 Project 2 Due 1159 PM on Sunday, March 28, 2021
CSCE 1030 Project 2 Due 1159 PM on Sunday, March 28, 2021CSCE 1030 Project 2 Due 1159 PM on Sunday, March 28, 2021
CSCE 1030 Project 2 Due 1159 PM on Sunday, March 28, 2021
 
Cpph exam a_2019_s1
Cpph exam a_2019_s1Cpph exam a_2019_s1
Cpph exam a_2019_s1
 
Java Practice Set
Java Practice SetJava Practice Set
Java Practice Set
 
Copying number ranges in SAP FICO ECC
Copying number ranges  in SAP FICO ECCCopying number ranges  in SAP FICO ECC
Copying number ranges in SAP FICO ECC
 
Statement of Operations and Financial StatementsSubmit written r.docx
Statement of Operations and Financial StatementsSubmit written r.docxStatement of Operations and Financial StatementsSubmit written r.docx
Statement of Operations and Financial StatementsSubmit written r.docx
 
C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2C - Programming Assignment 1 and 2
C - Programming Assignment 1 and 2
 
Railway ticket Simple Program
Railway ticket Simple ProgramRailway ticket Simple Program
Railway ticket Simple Program
 
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docxBTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
BTE 320-498 Summer 2017 Take Home Exam (200 poi.docx
 
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docxStudent Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
Student Lab Activity A. Lab # CIS CIS170A-A1B. Lab.docx
 

Recently uploaded

Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...VICTOR MAESTRE RAMIREZ
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfAsst.prof M.Gokilavani
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024Mark Billinghurst
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLDeelipZope
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...asadnawaz62
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerAnamika Sarkar
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxDeepakSakkari2
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineeringmalavadedarshan25
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxk795866
 

Recently uploaded (20)

young call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Serviceyoung call girls in Green Park🔝 9953056974 🔝 escort Service
young call girls in Green Park🔝 9953056974 🔝 escort Service
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...Software and Systems Engineering Standards: Verification and Validation of Sy...
Software and Systems Engineering Standards: Verification and Validation of Sy...
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdfCCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
CCS355 Neural Network & Deep Learning Unit II Notes with Question bank .pdf
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024IVE Industry Focused Event - Defence Sector 2024
IVE Industry Focused Event - Defence Sector 2024
 
Current Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCLCurrent Transformer Drawing and GTP for MSETCL
Current Transformer Drawing and GTP for MSETCL
 
complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...complete construction, environmental and economics information of biomass com...
complete construction, environmental and economics information of biomass com...
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube ExchangerStudy on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
Study on Air-Water & Water-Water Heat Exchange in a Finned Tube Exchanger
 
POWER SYSTEMS-1 Complete notes examples
POWER SYSTEMS-1 Complete notes  examplesPOWER SYSTEMS-1 Complete notes  examples
POWER SYSTEMS-1 Complete notes examples
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
Biology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptxBiology for Computer Engineers Course Handout.pptx
Biology for Computer Engineers Course Handout.pptx
 
Internship report on mechanical engineering
Internship report on mechanical engineeringInternship report on mechanical engineering
Internship report on mechanical engineering
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
Introduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptxIntroduction-To-Agricultural-Surveillance-Rover.pptx
Introduction-To-Agricultural-Surveillance-Rover.pptx
 

Programming - C++

  • 1. Practice questions: 1. Write a program in C++ to store registration of 100 students and their 7 courses. Calculate class average of each of course and display. 2. (Credit Limit Calculator) Develop a C program that will determine if a department store customer has exceeded the credit limit on a charge account. For each customer, the following facts are available: a. Account number b. Balance at the beginning of the month c. Total of all items charged by this customer this month d. Total of all credits applied to this customer's account this month e. Allowed credit limit The program should input each fact, calculate the new balance (= beginning balance + charges – credits), and determine whether the new balance exceeds the customer's credit limit. For those customers whose credit limit is exceeded, the program should display the customer's account number, credit limit, new balance and the message “Credit limit exceeded.” Here is a sample input/output dialog 3. One large chemical company pays its salespeople on a commission basis. The salespeople receive $200 per week plus 9% of their gross sales for that week. For example, a salesperson who sells $5000 worth of chemicals in a week receives $200 plus 9% of $5000, or a total of $650. Develop a program that will input each salesperson’s gross sales for last week and will calculate and display that salesperson’s earnings. Process one salesperson's figures at a time. Here is a sample input/output dialog: 4. The simple interest on a loan is calculated by the formula: Interest = principal * rate * days / 365;
  • 2. The preceding formula assumes that rate is the annual interest rate, and therefore includes the division by 365 (days). Develop a program that will input principal, rate and days for several loans, and will calculate and display the simple interest for each loan, using the preceding formula. Here is a sample input/output dialog: 5. Write a program that finds the smallest of several integers (without using array). Assume that the first value read specifies the number of values remaining. 6. One interesting application of computers is drawing graphs and bar charts (sometimes called “histograms”). Write a program that reads five numbers (each between 1 and 30). For each number read, your program should print a line containing that number of adjacent asterisks. For example, if your program reads the number seven, it should print *******. 7. An online retailer sells five different products whose retail prices are shown in the following table: Write a program that reads a series of pairs of numbers as follows: a) Product number b) Quantity sold for one day Your program should use a switch statement to help determine the retail price for each product. Your program should calculate and display the total retail value of all products sold last week. 8. (CalculatingWeeklyPay) A company pays its employees as managers (who receive a fixed weekly salary), hourly workers (who receive a fixed hourly wage for up to the first 40 hours they work and “time-and-a-half”—i.e., 1.5 times their hourly wage—for overtime hours worked), commission workers (who receive $250 plus 5.7% of their gross weekly sales), or pieceworkers (who receive a fixed amount of money for each of the items they produce— each pieceworker in this company works on only one type of item). Write a program to compute the weekly pay for each employee. You do not know the number of employees in advance. Each type of employee has its own pay code: Managers have paycode 1, hourly workers have code 2, commission workers have code 3 and pieceworkers have code 4. Use a switch to compute each employee’s pay based on that employee’s paycode. Within the switch, prompt the user (i.e., the payroll clerk) to enter the
  • 3. appropriate facts your program needs to calculate each employee’s pay based on that employee’s paycode. 9. Write a program that prints the following diamond shape 10. (Parking Charges)A parking garagecharges a $2.00minimum fee to parkforup to three hours and an additional$0.50 perhourfor each hour or part thereofoverthree hours. The maximum charge for any given 24-hour period is $10.00. Assume that no car parks for longer than 24 hours at a time. Write a programthat will calculate and print the parking charges for each of three customers who parked their cars in this garage yesterday. You should enter the hours parked foreach customer.Yourprogramshould print theresults in a tabularformat,and should calculate and print the total of yesterday's receipts. The program should use the function calculateCharges to determine the charge for each customer. Your outputs should appear in the following format: 11. (Hypotenuse Calculations) Define a function called hypotenuse that calculates the length of the hypotenuse of a right triangle when the other two sides are given. The function should take two arguments of type double and return the hypotenuse as a double. 12. (Square of Asterisks) Write a function that displays a solid square of asterisks whose side is specified in integer parameter side. For example, if side is 4, the function displays: 13. (Displaying a Square of Any Character) Modify the function created in Exercise 5.19 to form the square out of whatever character is contained in
  • 4. character parameter fillCharacter. Thus if side is 5 and fillCharacter is “#”, then this function should print: 14. (Separating Digits) Write program segments that accomplish each of the following: a. Calculate the integer part of the quotient when integer a is divided by integer b. b. Calculate the integer remainder when integer a is divided by integer b. c. Use the program pieces developed in a) and b) to write a function that inputs an integer between 1 and 32767 and prints it as a series of digits, with two spaces between each digit. For example, the integer 4562 should be printed as: 15. Given the following structure and variable definitions, struct customer { char lastName[ 15 ]; char firstName[ 15 ]; unsigned int customerNumber; struct { char phoneNumber[ 11 ]; char address[ 50 ]; char city[ 15 ]; char state[ 3 ]; char zipCode[ 6 ]; } personal; } customerRecord, *customerPtr; customerPtr = &customerRecord Write an expression that can be used to access the structure members in each of the following parts: a. Member lastName of structure customerRecord. b. Member lastName of the structure pointed to by customerPtr. c. Member firstName of structure customerRecord. d. Member firstName of the structure pointed to by customerPtr. e. Member customerNumber of structure customerRecord. f. Member customerNumber of the structure pointed to by customerPtr. g. Member phoneNumber of member personal of structure customerRecord. h. Member phoneNumber of member personal of the structure pointed to by customerPtr. i. Member address of member personal of structure customerRecord.
  • 5. j. Member address of member personal of the structure pointed to by customerPtr. k. Member city of member personal of structure customerRecord. l. Member city of member personal of the structure pointed to by customerPtr. m. Member state of member personal of structure customerRecord. n. Member state of member personal of the structure pointed to by customerPtr. o. Member zipCode of member personal of structure customerRecord. p. Member zipCode of member personal of the structure pointed to by customerPtr. 16. Write statements that accomplish each of the following. Assume that the structure struct person { char lastName[ 15 ]; char firstName[ 15 ]; char age[ 4 ]; }; has been defined and that the file is already open for writing. a. Initialize the file "nameage.dat" so that there are 100 records with lastName = "unassigned", firstname = "" and age = "0". b. Input 10 last names, first names and ages, and write them to the file. c. Update a record; if there’s no information in the record, tell the user "No info". d. Delete a record that has information by reinitializing that particular record.