Questions: 652

Answers by our Experts: 652

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering


Write a program that prints integers that are multiples of 5 in the range of 5 to 50. Name the program as follows: multiples_while.cpp. while loop program


1. Determine the exact output that is produced when the following code is executed. (7)


for x = 1 to 10 step 1


for y = 1 to x step 1


if y MOD 2 = 0 AND x MOD 2 <> 0 || y MOD 2 <> 0 AND x MOD 2 = 0 then


display "*"


else


display "#"


endif


next y


display " " ~newline


next x


2. Rewrite the following for-loop as a pre-test while-loop. (6)


for x = 1 to 10


for y = 10 to x


if y MOD 2 = 0 then


display "*"


else


display "#"


endif


display " " ~newline


3. Rewrite the following for-loop as a post-test do-loop. (5)


for x = 20 to -20 step -3


display "x = ", x


next x


4. Identify an error in the following pseudocode: (2)


sum = 0


for x = 1 to 10


if y MOD 2 = 0


display y


sum = sum + y

Rewrite the following for-loop as a pre-test while-loop. (6)



for x = 1 to 10



for y = 10 to x



if y MOD 2 = 0 then



display "*"



else



display "#"



endif



display " " ~newline




Solve the following problem by showing the design of your solution as an algorithm.


The problem – The program will take two integers from the user, say n1 and n2. It will then print the sum of all numbers between n1 and n2, inclusive. For example, if the user enters 5 and 9, the program will print the value of 5+6+7+8+9. On the other hand, if the user enters 5 and -2, the program will print the value of 5+4+3+2+1+0+(-1)+(-2). Note: Do not assume the user will always enter the smaller number first.

Using the Sieve Algorithm remove all non-prime numbers on the given below. (Show your complete solution.)



1. 2 3 4 5 12 13 15 24 25 29 38 39 43 57 58 61



2. 2 3 4 5 103 104 105 106 107 108 109 110 111 112 113 114 115

Using the consecutive Integer Checking Algorithm, solve the GCD of the following pair of numbers. (Show your complete solution.)



1. GCD (19, 7)

Solve for the Greatest Common Divisor (GCD) of the following pair of numbers using the Pseudocode of Euclidean Algorithm given



below. (Show your complete solution.)



while n ≠ 0 do



r ← m mod n



m ← n



n ← r



return m




1. GCD (248, 16)

Solve for the Greatest Common Divisor (GCD) of the following pair of numbers using the Basic Euclidean Algorithm. (Show your complete solution.) 1. GCD (700, 105)


You are to write a program that will allow the user to select from a menu of 3 movies available to watch. The menu should look like the following:

  1. Movie 1: Venom: Let There be Carnage
  2. Movie 2: Halloween Kills
  3. Movie 3: Vivo

If the user asks to watch Movie 1, ask for the number of tickets to buy and print the total to pay. The price per ticket for Movie 1 is $8.

If the user asks to watch Movie 2, then the program must ask for his/her age before it proceeds. If the user is younger than 18 years old, the program must print a message saying "Sorry you must be 18 or older to watch this movie." If the user is 18 or older, then proceed to ask how many tickets the user wants and print the total to pay. Price per ticket for Movie 2 is $10.

If the user asks to watch Movie 3, ask for the number of tickets to buy and print the total to pay. The price per ticket for Movie 3 is $6.50.



Write a program in C++ that will simulate a basic calculator. The program should present a menu to the user and ask the user to type an option. You should use the switch statement to execute the operation selected. The menu should have the following options: 


1. Add

2. Multiply

3.Subtract

4.Divide


The program should then ask for 2 numbers and perform the operation. For the 'Subtract' option, the program should check to see which number is greater then subtract the smaller number from the larger.



LATEST TUTORIALS
APPROVED BY CLIENTS