Concept explainers
The programmer intended the following pseudocode to get five sets of two numbers each, calculate the sum of each set, and calculate the sum of all the numbers entered. It will not function as intended, however. Find the error.
// This
Declare Integer number, sum, total
Declare Integer sets, numbers
Constant Integer MAX_SETS = 5
Constant Integer MAX_NUMBERS = 2
Set sum = 0;
Set total = 0;
For sets = 1 To MAX_NUMBERS
For numbers = 1 To MAX_SETS
Display "Enter number ", numbers, " of set ", sets, "."
Input number ;
Set sum = sum + number
End For
Display "The sum of set " sets, " is , sum, "."
Set total = total + sum
Set sum = 0
End For
Display "The total of all the sets is total , "."
Want to see the full answer?
Check out a sample textbook solutionChapter 5 Solutions
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Additional Engineering Textbook Solutions
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Concepts of Programming Languages (11th Edition)
Starting Out With Visual Basic (7th Edition)
Database Concepts (8th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
- The following program has syntax errors. Correct them. On each successive line, assume that any preceding error has been corrected. (12) const char = STAR = '*' const int PRIME = 71; int main { int count, sum; double x; count = 1; sum = count + PRIME; x = 25.67 newNum = count * ONE + 2; sum + count = sum; (x + sum) ++; x = x + sum * COUNT; sum += 3 ; cout " count = " count ", sum = " sum ", PRIME = " Prime endl; }arrow_forwardCode should be in Python, please 1. Prompt the user for data points. Data points must be in this format: string, int. Store the information before the comma into a string variable and the information after the comma into an integer. The user will enter -1 when they have finished entering data points. Output the data points. Store the string components of the data points in a list of strings. Store the integer components of the data points in a list of integers.Example: Enter a data point (-1 to stop input): Jane Austen, 6 Data string: Jane Austen Data integer: 6 2. Perform error checking for the data point entries. If any of the following errors occurs, output the appropriate error message and prompt again for a valid data point. If entry has no comma Output: Error: No comma in string. If entry has more than one comma Output: Error: Too many commas in input. If entry after the comma is not an integer Output: Error: Comma not followed by an integer. Example: Enter a data…arrow_forwardCode should be in Python, please 1. Prompt the user for data points. Data points must be in this format: string, int. Store the information before the comma into a string variable and the information after the comma into an integer. The user will enter -1 when they have finished entering data points. Output the data points. Store the string components of the data points in a list of strings. Store the integer components of the data points in a list of integers.Example: Enter a data point (-1 to stop input): Jane Austen, 6 Data string: Jane Austen Data integer: 6arrow_forward
- Hi, the follwing code is return by value but I want to make it return by reference ... please help #include<iostream> using namespace std; double cubeValue (double n) {//function which takes parameter and cubes it double c = n * n * n; return c;//return by value } int main () {//main function double number; cout << "Enter the number you wish to cube: "; cin >> number; double n = cubeValue (number);//calling function and storing return by value in n cout << "The number after cubing is: " << n << endl; }arrow_forward(Rounding Numbers) An application of function floor is rounding a value to the nearestinteger. The statementy = floor(x + .5);will round the number x to the nearest integer and assign the result to y. Write a program that readsseveral numbers and uses the preceding statement to round each of these numbers to the nearestinteger. For each number processed, print both the original number and the rounded number.arrow_forwardC++ code needed Design an application that accepts 10 numbers and displays them in descending order. // Pseudocode PLD Chapter 8 #1 pg. 366// Start// Declarations// num SIZE = 10// num NUMBERS[SIZE]// num i// num j// num temp// for i = 0 to SIZE - 1// output "Please enter a number: "// input NUMBERS[i]// endfor// for i = 0 to SIZE - 2// for j = 0 to SIZE - 2// if (NUMBERS[j] < NUMBERS[j+1])// temp = NUMBERS[j]// NUMBERS[j] = NUMBERS[j+1]// NUMBERS[j+1] = temp// endif// endfor// endfor// output "Sorted List"// output "==========="// for i = 0 to SIZE - 1// output "Number ", i + 1, ": ", NUMBERS[i]// endfor// Stoparrow_forward
- *Try to run the program then answer the following questions below* Here is the program: #include<iostream>using namespace std; int main (){int arr[10], num, x, y, z, highest, lowest;cout << "\nEnter the number of items to sort: ";cin >> num;cout << "Enter the numbers: "; for (x = 0; x < num; x++)cin >> arr[x];highest = arr[0]; for (x = 0; x < num; x++){if (highest < arr[x])highest = arr[x];}lowest = arr[0];for (x = 0; x < num; x++){if (lowest > arr[x])lowest = arr[x];} for(x=0; x<num; x++){ for(y=x+1; y<num; y++){if(arr[x]>arr[y]){z =arr[x];arr[x]=arr[y];arr[y]= z;}}}cout << "\n==============================================\n"; cout << "==============================================\n"; cout<<"\nLowest -> Highest:"<<endl <<endl;for(x=0; x<num; x++)cout << "\t"<<arr[x]<<" ";cout<<endl; for(x=0;x<num;x++){ for(y=x+1;y<num;y++){if(arr[x]<arr[y]){z =…arrow_forwardInclude pseudocode that describes all steps required to solve the problem. Employ variable names that describe the values they store and adhere to Python naming conventions. Include additional comments as needed to annotate your code. Use correct spelling and grammar. Use f_strings to output variable values. Use the "dunders test" for __name__ equals __main__ 1. Write a program that contains a main function and a custom, void function named show_larger that takes two random integers as parameters. This function should display which integer is larger and by how much. The difference must be expressed as a positive number if the random integers differ. If the random integers are the same, show_larger should handle that, too. See example outputs. In the main function, generate two random integers both in the range from 1 to 5 inclusive, and call show_larger with the integers as arguments.EXAMPLE OUTPUT 13 is larger than 1 by 2EXAMPLE OUTPUT 2The integers are equal, both are 3 2. Write a…arrow_forwardThe problem statement is described in the problem_statement.pdf file. Write the solution into the fuzzy_phrases/solution.py. Please do not change the input and output contract of the def phrasel_search(P, Queries) -> [[string]] function as the testing of the code correctness will be done programmatically. Note - You can only use standard python libraries. ex - json, random, etc So in the screenshots below we have one that has the instructions which has to be followed and executed , the next one that follows should be an example, that says sample example python this is the problem statement supposed to be used to give you an idea , showing how you should take the phrases to loop through the queries as a parameter. The other screenshot is called the solution output, that is the sample of how the code should look like but it has to be modified. and the other screenshot that says this is the first sample py, is the json file you want to loop through . Thank youarrow_forward
- Requirements: Include pseudocode that describes all steps required to solve the problem. Employ variable names that describe the values they store and adhere to Python naming conventions. Include additional comments as needed to annotate your code. Use correct spelling and grammar. Use f-strings to generate currency outputsQuestion: 1. Write a program that contains a main function and a custom, void function named show_larger that takes two random integers as parameters. This function should display which integer is larger and by how much. The difference must be expressed as a positive number if the random integers differ. If the random integers are the same, show_larger should handle that, too. See example outputs. In the main function, generate two random integers both in the range from 1 to 5 inclusive, and call show_larger with the integers as arguments.EXAMPLE OUTPUT 13 is larger than 1 by 2EXAMPLE OUTPUT 2The integers are equal, both are 3arrow_forwardQ1) Weight initialization should generate random numbers in the range [-r,r]. * Please provide the python language code that does this function. Q2) You want to train a classifier when you have many unlabeled training data but only a few thousand labeled data. Describe how the autoencoder can be helpful and how to work.arrow_forwardThis program will compute the summary of two numbers, num1 and num2. A function called sum will compute the sum num1 and num2, and return the summed value to the main program. The function sum will not display anything. The main program will display the result. #include <iostream> #include <iomanip> using namespace std; //function prototype double sum(double,double); int main() { double a,b; cout<<"Enter a: \n"; cin>>a; cout<<"Enter b: \n"; cin>>b; cout<<"The summary of "<<a<<" and "<<b<<" is: "; cout<<sum(a,b)<<endl; return 0; } //function body ______________________________________________________ ______________________________________________________ ______________________________________________________ ______________________________________________________ ______________________________________________________arrow_forward
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning