Supplied code Document
/ Ch13_Ex11_MainProgram.cpp - given code below
// Ch13_Ex11_MainProgram.cpp - given code below // #include "stdafx.h" may uncomment this if Visual Studios requires
#include <iostream>
#include "myArray.h"
using namespace std;
int main()
{
// Creates list1 and list2
myArray list1(5);
myArray list2(5);
// Zeroing (initializing) first array
int i;
cout << "list1 : ";
for (i = 0; i < 5; i++)
cout << list1[i] << " ";
cout << endl;
// Prompt to enter five numbers into list1
cout << "Enter 5 integers: ";
for (i = 0; i < 5; i++)
cin >> list1[i];
cout << endl;
// show contents list1
cout << "After filling list1: ";
for (i = 0; i < 5; i++)
cout << list1[i] << " ";
cout << endl;
// Transfer five elements from list1 to list2, Print list2
list2 = list1;
cout << "list2 : ";
for (i = 0; i < 5; i++)
cout << list2[i] << " ";
cout << endl;
// Write three elements replacing first 3 of list1
cout << "Enter 3 elements: ";
for (i = 0; i < 3; i++)
cin >> list1[i];
cout << endl;
// Prints three elements of list1 just entered
cout << "First three elements of list1: " << endl;
for (i = 0; i < 3; i++)
cout << list1[i] << " ";
cout << endl;
// Create list3 for first time
// Induced Chaos by
// cramming -2 to 6 into array list3
myArray list3(-2, 6);
// Print 8 array location numbers from -2 through 5
// Should print zero eight times if memory is initialized
cout << "list3: ";
for (i = -2; i < 6; i++) cout << list3[i] << " ";
cout << endl;
list3[-2] = 7;
list3[4] = 8;
list3[0] = 54;
list3[2] = list3[4] + list3[-2];
// Print results to screen
cout << "list3: ";
for (i = -2; i < 6; i++)
cout << list3[i] << " ";
cout << endl;
system("pause");
return 0;
}
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
Could you please look at step 3, for some reasons I am getting errors?
Could you please look at step 3, for some reasons I am getting errors?
- Python question please include all steps and screenshot of code. Also please provide a docstring, and comments throughout the code, and test the given examples below. Thanks. Write a function called honorRoll(). Its only input parameter is a list that contains listsconsisting of a name followed by a series of grades (integers). All grades will be in therange 0-100. All students will have at least one grade, but not all students will have thesame number of grades. Your function should return a list of students whose averagegrade is above 92.0.>>> honorRoll([['Alice', 95, 92, 98], ['Carlos', 85, 87, 95, 91], ['Betty', 81, 74, 89]])['Alice']>>> honorRoll([['Alice', 92, 92, 92], ['Bob', 81, 46]])[]arrow_forwardAfter a tuple is created, its items can be changed. True False A tuple's items can be access by square brackets, similar to lists. True Falsearrow_forwardvrite a each eler the original assigns the element with 0. Ex: lowerScores = {5, 0, 2, -3} becomes {4, 0, 1, 0}. 406554.2871636.qx3zqy7 1 #include 2 #include 3 using namespace std; 4 5 int main() { 6 7 9 10 11 12 13 14 15 16 17 Run const int SCORES_SIZE = 4; vector lowerScores (SCORES_SIZE); unsigned int i; for (i 0; i > lowerScores.at(i); } /* Your solution goes here */ for (i = 0; i < lowerScores.size(); ++i) { cout << lowerScores.at (i) << " "; nent was greater than 0, and oth wise.arrow_forward
- POEM List[POEM_LINE] PRONUNCIATION_DICT Dict[str, PHONEMES] Do not add statements that call print, input, or open, or use an import statement. Do not use any break or continue statements.arrow_forwardpython help, please show all steps and include comments Write a function largerLst() that takes a list of numbers (i.e., int or float values) as a parameter and returns a new list constructed out of it. The list returned has all the values in the parameter list that are larger than the element immediately to their right, that is, larger than their right neighbor. If the parameter list is empty or there are no values larger than their right neighbor, then the function returns an empty list. Note that the last element in the list will never be included in the list returned since it does not have a right neighbor. The function should not change the parameter list in any way. Note that a correct solution to this problem must use an indexed loop That is, one that makes a call to the range() function to generate indices into the list which are used to solve the problem (Review lecture notes 8-1). A solution that does not use an indexed loop will not be accepted. Note in particular that you…arrow_forwardLottery number generator: Write a program that generates aseven-digit lottery number. The program should have a loopto generate seven random numbers, each in the range 0through 9 and assign each number to a list element.2. Write another loop to display the contents of the list.3. Tip: You will need to create/initialize your list before you canassign numbers to it.4. Use program 7-1 sales_list as an example. You will start witha seven-digit lottery number that contains all zeros. Then inyour loop, you will assign a random number instead ofgetting the data from the user.Turn in your program to the practice assignment link in coursecontent.arrow_forward
- Cassignm222 Assignment 2 features designing a program using pseudocode and then completing the program in Python using a list. M4Lab2 asks you to write a Drawing app in Python and Pygame using a list for the colors. Each lab asks you to write pseudocode that plans the program's logic before you write the program in Python and to turn in three things: 1) the pseudocode, 2) a screenshot of the output, and 3) the Python program. # Step 1: Define a colors list to describe 3 colors.# Hint, use their RGB number values Step 2: define a radius variable for your pen at 5, 10 or 15# Test them to see which radius you prefer and use it # Step 3: write the elif for pressing button 2, similar to button 1 # Step 4: write the statement for button 2's color # Step 5: write the else statement for button 3 # Step 6: choose a color from the list??arrow_forward6. list_n_perfect_squares This function takes a positive integer, n, and returns a list containing n perfect square numbers, starting with 1 and counting up to n2 Use a list comprehension and a range! Sample runs should look like: >>> list_n_perfect_squares ( 6) [1, 4, 9, 16, 25, 36] >>> list_n_perfect_squares (1) [1] >>> list_n_perfect_squares (20) [1, 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400]arrow_forward11111 2) Name: 2. The following procedure is intended to return the number of times the value val appears in the list myList. The procedure does not work as intended. Line 01: PROCEDURE countNumOccurences (myList, val) Line 02: { Line 03: FOR EACH item IN myList Line 04: } BL Line 05: count 0 Line 06: IF(item = val) %3D Line 07: Line 08: count count + 1 :60 Line 10: { { RETURN(count) Line 11: Line 12: } Which of the following changes can be made so that the procedure will work as intended? a. Moving the statement in line 5 so that it appears between lines 2 and 3 C. Changing line 6 to IF(item = count) b. Changing line 6 to IF(myList[item] = val) d. Moving the statement in line 11 so that it appears between lines 9 and 10arrow_forward
- Python Programmingarrow_forward5. Charge Account Validation If you have downloaded the source code from the Computer Science Portal you will find a file named charge_accounts.txt in the Chapter 07 folder. This file has a list of a com- pany's valid charge account numbers. Each account number is a seven-digit number, such as 5658845. Programming Exercises 403 program Write a program that reads the contents of the file into a list. The program should then ask the user to enter a charge account number. The program should determine whether the number is valid by searching for it in the list. If the number is in the list, the should display a message indicating the number is valid. If the number is not in the list, the program should display a message indicating the number is invalid. (You can access thearrow_forward#include <iostream>#include <iomanip>#include <string>using namespace std;struct menuItemType{string menuItem;double menuPrice;};void getData(menuItemType menuList[]);void showMenu(menuItemType menuList[] , int n);void printCheck(menuItemType menuList[], int menu_order[], int n);int main(){const int item = 8;menuItemType menuList[item];int menu_order[item] ={0};int choice =0;int count =0;bool order = true;getData(menuList);showMenu(menuList,item);while(order){cout<<"Enter the choice for the order or press 0 to exit"<<endl;cin>>choice;if(choice>0 && choice<=item){menu_order[choice-1]+=1;}else{order=false;}}printCheck(menuList,menu_order,item);return 0;}void getData(menuItemType menuList[]){menuItemType plainEgg;menuItemType baconEgg;menuItemType muffin;menuItemType frenchToast;menuItemType fruitBasket;menuItemType cereal;menuItemType coffee;menuItemType tea;plainEgg.menuItem = "Plain Egg";plainEgg.menuPrice = 1.45;baconEgg.menuItem =…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education