First try to predict how many times will the following for loops execute? What is the output? for (i = 17; i>1; i = i/2) for (j = 2; j
Q: Solve in c programming language. Use do-while loop for this question and use both press 'Y to…
A: PROGRAM CODE: #include <stdio.h> // include header file for standard input…
Q: 4) Using a loop, extend the program to handle multiple lines of input. Continue until the user…
A: The given code is written in c where it takes the string input from user having a , (comma) in it…
Q: Given the following for loop, write a main program for it and rewrite the code so that it executes…
A: Answer: According to the given condition, the while loop block is Int i = 3; While (i < 18) {…
Q: PROBLEM: Write a C++ program that will accept 3 strings (these should be of different sizes) then…
A: ALGORITHM:- 1. Take input for the strings from the user. 2. If size is greater than display error…
Q: Use switch-case statements for this program. Write a menu-driven c program which has the following…
A: Switch Statement is a multiple is a multiple choice selection statement. It will be executed…
Q: 5. Input integer x and y, the following figure shows the flow chart of program. Please design test…
A: In the above given flow chart we are supposed to enter the values of x and y . First Decision Box is…
Q: Q1) Write a C++ program to compute the value of S using function called Compute_S(x, n), where the…
A: Here I have created the function pwr(). In this function if the value of y is 0 then return 1,…
Q: Write a C program that reads a double value (x) from the user and then uses it to compute the value…
A: Programming Approach: Defining a header file. Declaring method power which takes the variable x…
Q: PROBLEM: Write a C++ program that will accept 3 strings (these should be of different sizes) then…
A: I have provided C++ CODE along with CODE SCREENSHOT and TWO OUTPUT…
Q: a) Consider the following series, this series will evaluate the value of Y(x) from n = 1 up to…
A: Here I have first of all asked the user to enter the value of x. Now I have checked the value of x…
Q: Q1) Write a C++ program to compute the value of S using function called Compute_S(x, n), where the…
A: *using c++ to compute the series for given condition…
Q: bläi 6 Rewrite the code segment bellow by using switch statement instead of if- .else statement If…
A: PROGRAM CODE: #include <iostream> // include header file for input output stream…
Q: To learn how nested for loops work do a walk-through of the following program segment and determine…
A: #include <iostream>#include <iomanip> using namespace std; int main(){ int i, j, M =…
Q: 5. Write a C program to compute the value of Euler's number that is used as the base of natural…
A: I give the code in C along with explanation and output screenshot
Q: Use your new found knowledge of iterative (looping) statements in C# to write a program that will…
A: Algorithm: Start Initialize i=1,k=0.00,n=1,p=0.00,j=1,m=0.00 Using while loop i<=20 print i…
Q: (a) ask the item price from the user (b) ask how many items to purchase for a specific item price…
A: As we are not sure about the number of items, to be added we can make use of loops to accept input…
Q: Example 1: Write, compile and execute a C++ program using while loop statement to print your name…
A: I have provided solution in step2.
Q: ) You are tasked with calculating the cost of PCs for a new computer lab. Write a C++ program to: -…
A: Required: You are tasked with calculating the cost of PCs for a new computer lab. Write a C++program…
Q: -what is the Continue statement doing ? A) Terminate execution of while or for loop B) passes…
A: continue is a keyword used in loops This makes the later instructions present after continue gets…
Q: Program C 3. Loading… by CodeChum Admin I wanna experiment on looping through a range of numbers…
A: The C code along with the snapshot of code and output is given below.
Q: Modify c so that the function delay takes an int cycles as an argument. The for loop in delay…
A: The program is written in c to get the output as mentioned .
Q: programs for the following problem statements.a) Write a postcondition, event-controlled loop…
A: as per Bartleby guidelines we are supposed to answer?️ only one question. Kindly repost other…
Q: 4. Make a C program that will display the following number series: 99, 80, 63, 48, 35, 24, 15, 8, 3,…
A: CODE: OUTPUT: 90 80 63 48 35 24 15 8 3 0
Q: Write a complete C+ program that read the values of major axis and minor axis from input file,…
A: Solution: Programming language used: C++ Note: store input file data.txt in same location of…
Q: user-defined function and appropriate conditional and looping statements, create a program using C++…
A: Explanation: Detail Code #include <bits/stdc++.h>using namespace std; int main(){ int…
Q: write a c++ program: Your time machine is capable of going forward in time up to 24 hours. The…
A: As you have not provided the sample output, so we have provided the output in most appropriate and…
Q: Define the minimum number of test cases required for full statement, branch, and path coverage for…
A: Full statement: The statement is the entity in the programming language, it is the smallest…
Q: 1. Start with analysing the problem by using a flowchartipseudo code. 2. As mention above, buikd a…
A: The program for the above question is as follows:
Q: Q1: Write a C# program that finds the value of Y from the following series: xn X x² x3 + 3! 5! 7! +…
A: BELOW COMPLETE PROGRAM INCLUDED WITH COMMENTS AND SCREENSHOT OF OUTPUT .
Q: write a c++ program for following: Please type in the total number of data values to be added: In…
A: Q. Write a c++ program for following: Please type in the total number of data values to be added: In…
Q: i₁(x) == fv₁ (x) dx Write a C program that calculates the area under a curve for the function: v₁(x)…
A: // Used for input & output functions #include <stdio.h> // Used for math functions…
Q: You are tasked with calculating the cost of PCs for a new computer lab. Write a C++ program to: -…
A: C++ program to calculate the cost of the PCs for a new computer lab. Prompt the user to enter the…
Q: Q1: Write a C# program that finds the value of Y from the following series: x5 x7 x2n+1 Y= x³_ + ±…
A: The C# code is given below with output screenshot As C# is an object-oriented programming language,…
Q: Gordon Ramsay has N strange bottles of sauces. The i-th bottle is opened by tapping exactly A¡…
A: Given: -
Q: Q1: Write a C# program that finds the value of Y from the following series: x5 x7 x2n+1 Y= x³ + + 2!…
A: The correct answer for the above mentioned question is given in the following steps for your…
Q: Create a c program that evaluates a quadratic function x^2 +5x +6. The main program will call a…
A: Program description: The main.c C program objective is a prompt user to enter the x value. Then the…
Q: The ceil(x) function is applicable to both int and double/floating point data type. (True or False)…
A: ceil() method rounds the particular double/floating value and returns the smallest integer which is…
Q: Write a C++ program to find GCD of two numbers. Conditions- 1.Write function GCD(int a,int b) 2.…
A: - The question is to find the GCD of two numbers using a function with one line of code. - We can…
Q: Write the syntax for a do/while loop that executes as long as a character variable has a value of…
A: the code is given below:
Q: If hours is greater than 18, print a message saying "This is an overload"; otherwise print a message…
A: #include <iostream> using namespace std; int main(){ int hours; cout<<"Enter…
Q: Load AC from memory, 0010 = Store AC to memory , 0101 = Add to AC from memory Where we have three…
A: It is defined as memory is a device or system that is used to store information for immediate use in…
Q: 1. a. A technical supplier tests four generators by measuring their output voltages at three…
A: For the given problem :- Input : We will take input as "Matrix of voltages and equipment number".…
Q: b) Write a C++ program, which uses a 'switch' statement to respond to different inputs from a user.…
A: Here the switch case will have 3 cases and one default case if input is not 1 or 2 or 3.
Q: Design a C++ program to do the administration for a fun run competition. Participants can run a…
A: Registration fees for club members are as follows:5km = R 65.0010km = R 100.0015km = R 150.00…
Q: This progran will output a parallelogram. How long do you want each side to be? 5 Please enter the…
A: 1. Implementation of the repeatChar(numRepeats, outputChar) method: def repeatChar(numRepeats,…
Q: If hours is greater than 18, print a message saying "This is an overload"; otherwise print a message…
A: #include <iostream> using namespace std; int main(){ int hours; cout<<"Enter…
Q: Q1: Write a C# program that finds the value of Y from the following series: x² x3 xn + ± (2n+1)! Y=…
A: The answer for the above mentioned question is given in the below steps for your reference.`
c++
6. First try to predict how many times will the following for loops execute? What is the output?
for (i = 17; i>1; i = i/2)
for (j = 2; j <i; j = j + 3)
cout << j << i+j << endl;
Then create a main
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images
- Write the number of for statement/ while loops that will be performed in a C++ program for each of the following: Initialization Condition Update Loops? a) i = 2 i <= 20 i = i + 1 18 b) i = 1 i < 10 i = i + 3 2 c) i = 28 i <= 28 i = i – 1 28 d) i = 1 i > 16 i = i * 4 e) i = -20 i < 50 i = i – 10 f) i = 17 i > 9 i = i – 2 g) i = 14 i != 8 i = i – 2 h) i = 29 while(1) i = i + 1A criticism of the break statement and the continue statement is that each is unstructured.Actually, break statements and continue statements can always be replaced by structured statements, although doing so can be awkward. Describe in general how you would remove any breakstatement from a loop in a program and replace that statement with some structured equivalent.[Hint: The break statement leaves a loop from within the body of the loop. The other way to leaveis by failing the loop-continuation test. Consider using in the loop-continuation test a second testthat indicates “early exit because of a ‘break’ condition.”] Use the technique you developed here toremove the break statement from the program of Fig. 4.11Write a C++ program (using cout and cin) that calculates a student's GPA. Ask the user to enter grade and also the credit hours of the course in a loop until user enter “N” or “n”. Earned points in that course becomes Grade point * credit hours i.e., Earned points = Grade point*credit hours Grade points of each grade are as follows Grade Grade Points A 4 B 3 C 2 D 1 F 0 Example: You got “A” grade in Computer Programming theory course and the credit hours are 3. So your earned grade points=4*3=12 Similarly if you get “C” grade in another subject e.g., Computer Fundamentals and the credit hours are also 3 here. Now earned grade points = 2*3=6 If you get “B” grade in Circuit and Systems theory and the credit hours are 3. So your earned grade points=3*3=9 Now your GPA = (12+6+9) / 9 = 3
- Write a C++program (using cout and cin) that calculates a student's GPA. Ask the user to enter grade and also the credit hours of the course in a loop until user enter “N” or “n”. Earned points in that course becomes Grade point * credit hours i.e., Earned points = Grade point*credit hours Grade points of each grade are as follows Grade Grade Points A 4 B 3 C 2 D 1 F 0 Example: You got “A” grade in Computer Programming theory course and the credit hours are 3. So your earned grade points=4*3=12 Similarly if you get “C” grade in another subject e.g., Computer Fundamentals and the credit hours are also 3 here. Now earned grade points = 2*3=6 If you get “B” grade in Circuit and Systems theory and the credit hours are 3. So your earned grade points=3*3=9 Now your GPA = (12+6+9) / 9 = 3 GPA formula is: GPA=Sum of earned points in all subjects / Total credit hoursUse C++ Write a program that simulates flipping a coin to make decisions. The input is how many decisions are needed, and the output is either heads or tails. Assume the input is a value greater than 0. Ex: If the input is: 3 the output is: heads tails heads For reproducibility needed for auto-grading, seed the program with a value of 2. In a real program, you would seed with the current time. In that case, every program's output would be different, which is what is desired but can't be auto-graded. Note: A common student mistake is to call srand() before each call to rand(). But seeding should only be done once, at the start of the program, after which rand() can be called any number of times. Your program must define and call the following function that returns "heads" or "tails".string HeadsOrTails()Questions:1. A criticism of the break and continue statements is that each is unstructured. These statements can always be replaced by structured statements. Describe in general how you’d remove any break statement from a loop in a program and replace it with some structured equivalent. [Hint: The break statement leaves a loop from within the body ofthe loop. Another way to leave is by failing the loop-continuation test. Consider using in theloop-continuation test a second test that indicates “early exit because of a ‘break’ condition.”] Use the technique you developed here to remove the break statement from the program of Fig. 5.13. 2. Write a program that uses for statements to print the following patterns separately, one below the other. Use for loops to generate the patterns. All asterisks (*) should be printed by a single statement of the form cout << '*'; (this causes the asterisks to print side by side). [Hint: The last two patterns require that each line begin with an…
- Programming Practice a) Write a program which allows a teacher to determine the min, max, and average grade from grades entered. The teacher will continuously enter grades until the sentinel is specified. For this example, a grade of -1 will be used to denote grading is completed. The min, max, and average grade should then be displayed to the teacher. This program should not accept invalid grades to be used [0, 100]. b) Write a program which outputs prime numbers up to a specified number. For example, if a user entered the number 25, the program would output the prime numbers between 1 and 25. c) Write a program which converts a sum of currency into the highest available denominations in terms of coins. For example, the user inputs the number 4.25. The program would output that it takes 2 Toonies and 1 Quarter. Ensure that the result uses the least amount of coins possible. This can be solved mathematically or using loops.Consider the following for loop. int j, s;s = 0;for (j = 1; j <= 10; j++)s = s + j * (j - 1);In this for loop, identify the loop control variable, the initialization statement, loop condition, the update statement, and the statement that updates the value of s.A criticism of the break and continue statements is that each is unstructured. These statements can always be replaced by structured statements. Describe in general how you’d remove any break statement from a loop in a program and replace it with some structured equivalent. [Hint: The break statement leaves a loop from within the body ofthe loop. Another way to leave is by failing the loop-continuation test. Consider using in theloop-continuation test a second test that indicates “early exit because of a ‘break’ condition.”] Use the technique you developed here to remove the break statement from the program of Fig. 5.13.
- A criticism of the break and continue statements is that each is unstructured. These statements can always be replaced by structured statements. Describe in general how you’d remove any break statement from a loop in a program and replace it with some structured equivalent. [Hint: The break statement leaves a loop from within the body ofthe loop. Another way to leave is by failing the loop-continuation test. Consider using in theloop-continuation test a second test that indicates “early exit because of a ‘break’ condition.”]An electrical manufacturer test five generators by measuring their output voltages at three at three different times. Write a C++ program that uses a nested loop to enter each generator’s test results and then computes and displays the average voltage for each generator. Finally, compute for the total average for all generators. Assume the following generator test results. 1st generator 122.5 122.7 123.0 2nd generator 120.2 127.0 125.1 3rd generator 121.7 124.9 126.0 4th generator 122.9 123.8 126.7 5th generator 121.5 124.7 122.6Write a C++ program using loops for a number guessing game. The program generates and stores a random number and prompts a user to guess the number. If user guess is less than the number, display “Sorry, guess is too low”, if user guess is greater than the number, display “Sorry, guess is too high”. If user guesses the right number, display “Congratulations, you have guessed the number”, and number of users tries to guess a number. The program should keep on taking a user input, until user guesses the number. Sample Output 1 (Number 50): Enter a number to guess: 50 “Congratulations, you have guessed the number” in first try. Sample Output 2 (Number 50): Enter a number to guess: 25 “Sorry, guess is too low” Enter a number to guess: 60 “Sorry, guess is too high” Enter a number to guess: 50 “Congratulations, you have guessed the number in 3 tries”, 2.12.0.0