< C++ Programming | Exercises
Q6a[edit]
Nov 29, 2016 Download Dev-C for free. A free, portable, fast and simple C/C IDE. A new and improved fork of Bloodshed Dev-C.
Write a program named question6a.cpp that will calculate and print pay slips. User inputs are the name of the employee,the number of hours worked and the hourly pay rate. You have to declare three functions.d) one for input;e) one to calculate the employee’s pay; andf) one to print the payslip.The input function has to input the name of the employee, the number of hours worked and the hourly pay rate into thevariables theEmployee, theHoursWorked and thePayRate. The variable employee is a string and the other twovariables are of type float. As the values of theEmployee, theHoursWorked and thePayRate will be changed inthis function, reference parameters need to be used.The calculation function will receive two parameters that represent the number of hours worked and the hourly pay rate,do the calculation and return the pay for the employee. An employee, who has worked more than 40 hours, is paid 1.5times the hourly pay rate for each hour of overtime. As the parameters are not changed in the function, they should bevalue parameters. The function should return a float value which represents the pay.The output function has to display the name of the employee, the number of hours worked, the number of overtime hoursand the hourly pay rate entered by the user as well as the employee’s pay. For example:
Jun 03, 2015 Switch case programming exercises and solutions in C June 3, 2015 Pankaj C programming C, Exercises, Programming, Switch switch case is a branching statement used to perform action based on available choices, instead of making decisions based on conditions. C For Loop. When you know exactly how many times you want to loop through a block of code, use the for loop instead of a while loop. Example explained. Line 1: #include is a header file library that lets us work with input and output objects, such as cout (used in line 5). Header files add functionality to C programs. C exercises. C exercises will help you test your knowledge and skill of programming in C and practice the C programming language concepts. You will start from basic C exercises to more complex exercises. The solution is provided for each exercise. You should try to solve each problem by yourself first before you check the solution. C while and do.while Loop Loops are used in programming to repeat a specific block of code. In this article, you will learn to create while and do.while loops in C programming.
Pay slip for Harry MatsipeHours worked: 43.5 hoursOvertime hours: 3.5Hourly pay rate: R125.35Pay: R5672.09
The main function includes a for loop that allows the user to repeat the calculation of a pay slip for five employees. Wegive the main function below. You must submit the three functions you have developed as well as output for repeatingthe loop five times with the following input data:Harry Matsipe 43.5 125.35Ellen Malan 39.4 112.75Joey Rashdien 40 120.45Mpho Bopape 41.2 123.60Veli Singh 39.7 135.30
![Dev Dev](/uploads/1/2/5/7/125719676/962159374.png)
Q6b[edit]
Dev C++ Online
NuMetro has a special on movies for all members of the public but special discounts for students and pensioners. Ifpensioners or students buy a movie ticket they receive 10% if they buy a movie and popcorns, they receive 20% discount. 100Other customers only receive a discount when they buy a movie ticket and popcorn; there is no discount for just a movieticket alone. Write a program named question6b.cpp that will consist of two functions. The program must prompt theuser for type of customer (‘p’ for pensioner, ‘s’ for student, ‘o’ for other). It must then call the relevant function accordingto that entry. The first function must receive the customer type and calculates discount for pensioners and students. Thesecond function calculates the discount for customers that are not pensioners or students.
Dev C++ Exercises
Q6c[edit]
![Dev Dev](/uploads/1/2/5/7/125719676/876944469.jpg)
Write a program named question6c.cpp that demonstrates the use of the following functions. A C++ function namedgetName()prompts the user for two string values; first name and last name and return a combination of the two asone value. The second function getHours()calculate employee’s weekly pay, it must receive one argument,fullName, a string variable and a float value for the rate. It must then prompt the user for hours worked for eachday of the week, i.e. Monday – Friday and calculates the weekly pay. Employees who have worked more than 40 hoursthat week will receive a bonus of 10% and those who have worked less than 40 hour will receive 10% less pay for thatweek.
This is done by using JavaScript to gather as much information about the computer as it can. When you visit a website that employs fingerprinting, usually embedded in an ad frame on the site, a fingerprint is extracted. ![Memory](/uploads/1/2/5/7/125719676/227843295.png)
![Memory](/uploads/1/2/5/7/125719676/227843295.png)
Retrieved from 'https://en.wikibooks.org/w/index.php?title=C%2B%2B_Programming/Exercises/Iterations&oldid=3434151'
Dev C++ Exercises Using Studio
Originally released by Bloodshed Software, but abandoned in 2006, it has recently been forked by Orwell, including a choice of more recent compilers. It can be downloaded from:
http://orwelldevcpp.blogspot.com
Installation
Run the downloaded executable file, and follow its instructions. The default options are fine.Support for C++11
By default, support for the most recent version of C++ is not enabled. It shall be explicitly enabled by going to:Tools -> Compiler Options
Here, select the 'Settings' tab, and within it, the 'Code Generation' tab. There, in 'Language standard (-std)' select 'ISO C++ 11':
Ok that. You are now ready to compile C++11!
Compiling console applications
To compile and run simple console applications such as those used as examples in these tutorials it is enough with opening the file with Dev-C++ and hitF11
.As an example, try:
File -> New -> Source File
(or Ctrl+N
)There, write the following:
Then:
File -> Save As..
(or Ctrl+Alt+S
)And save it with some file name with a
.cpp
extension, such as example.cpp
.Now, hitting
F11
should compile and run the program.If you get an error on the type of
x
, the compiler does not understand the new meaning given to auto
since C++11. Please, make sure you downloaded the latest version as linked above, and that you enabled the compiler options to compile C++11 as described above.