What is the purpose of commenting and how should it be done?
Each frame except for the tenth consists of one or
two balls, or attempts to knock down the ten pins at the end of the alley. Doing so on the
first ball of the frame is called a strike, and the second ball of the frame is not rolled.
Knocking down all ten pins with both balls (having left some up with the first ball) is called a
spare. If both attempts to knock down the pins leave some standing, the frame is called an
open frame. A spare in the tenth frame gives the bowler one extra ball; a strike in the tenth
gives him or her two extra balls. A bowling score is computed as follows. A strike counts as
10 points plus the sum of the next two balls. A spare counts as 10 points plus the next ball.
Suppose for example that the sequence of balls was
9 1 10 10 10 6 2 7 3 8 2 10 9 0 9 1 1 0
The score for the ten frames would be
Frame score
----- ----- 1 10
2 30
3 56
4 74
5 82
6 100
7 120
8 139
9 148
10 168
write a program that create the following number patern.
1 2 3 4 5 6 7 8 9
1 2 3 4 5 6 7 8
1 2 3 4 5 6 7
1 2 3 4 5 6
1 2 3 4 5
1 2 3 4
1 2 3
If the originally x=2 ,y=1 and z=1, what are the value of x, y, z after executing the
following code?
Switch(x)
{
case 0 : x = 2;
y =3;
case 1 : x =4;
Default:
y = 3;
x = 1;
}
Re write the following code fragment using one switch statement
if (ch = = ‘E’|| ch= = ‘e’)
cout<<" this is either the value of ‘E’ or ‘e’";
else if (ch = = ‘A’|| ch= = ‘a’)
cout<<" this is either the value of ‘A’ or ‘a’";
else if (ch = = ‘r’|| ch= = ‘i’)
cout<<" this is either the value of ‘i’ or ‘r’";
else
cout<<" Enter the correct choice";
Write a C++ program for the following flowchart. N.B Let the user enter the
initial value of X and Y, finaly your program should return the value of X, Y and
Z.
Write a program that prompts the user to input an integer and then outputs both the individual digits of the number and the sum of the digits. For example, it should output the individual digits of 3456 as 3 4 5 6, output the individual digits of 8030 as 8 0 3 0, output the individual digits of 2345526 as 2 3 4 5 5 2 6, output the individual digits of 4000 as 4 0 0 0, and output the individual digits of -2345 as 2 3 4 5.
Suppose the Road Transport Department (JPJ) intends to introduce a new compound system for speeding offenses on highways throughout Malaysia. JPJ hires your company to create a program to calculate and display the amount of compound that the driver has to pay. The program should ask the user to enter the speed limit and the speed of the vehicle in km/h units. If the speed does not exceed the speed limit, the program should display the message ‘innocent driver’.
The amount of the fine is calculated using the following method:
The basic fine is RM100. If the speed of the vehicle exceeds the speed limit of 20km/h or more, the total fine is the basic fine plus RM10 for each km/h that exceeds the speed limit. If the speed of the vehicle exceeds the speed limit, but the difference is less than 20km/h, the total fine is the basic fine plus RM5 for each km/h that exceeds the speed limit. The maximum fine is RM500.
Use bubble sort to sort following elements: 42, 78, 12, 32, 7, 54, 22, 3
write a program in c++ that inputs semester wise grades of a student along with subjects and print the transcript of awards of student