Starting Out with C++ from Control Structures to Objects (9th Edition)
9th Edition
ISBN: 9780134498379
Author: Tony Gaddis
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 7.3, Problem 7.6CP
What is the output of the following code?
int values[5], count;
for (count = 0; count < 5; count++)
values[count] = count + 1;
for (count = 0; count < 5; count++)
cout ≪ values[count] ≪ endl;
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
#include <stdio.h>
struct dna
{
int number;
char text;
char stringvalue[30];
};
int main()
{
struct dna dnavalue[5];
int i;
for(i=0; i<4; i++)
{
printf("Sample %d\n",i+1);
printf("Enter Number:\n");
scanf("%d", &dnavalue[i].number);
printf("Enter Text :\n");
scanf("%c",&dnavalue[i].text);
printf("Enter String :\n");
scanf("%s",dnavalue[i].stringvalue);
}
printf("Sample DNA Number Text String\n");
for(i=0; i<4; i++)
{
printf("%d\t\t", i+1);
printf("%d\t\t", dnavalue[i].number);
printf("%c\t\t", dnavalue[i].text);
printf("%s", dnavalue[i].stringvalue);
printf("\n");
}
return 0;
}
Write comments on every line of this program explaining what's happening briefly
int X[10]={2,0,6,11,4,5,9,11,-2,-1);
From the code above, what is the value of X[8] ?
char[] X = { ‘A’, ‘E’, ‘I’, ‘O’, ‘U’, ‘V’}; What is the value of X[2]?
a.
I
b.
U
c.
E
d.
O
Chapter 7 Solutions
Starting Out with C++ from Control Structures to Objects (9th Edition)
Ch. 7.3 - Define the following arrays: A) empNums, a...Ch. 7.3 - Prob. 7.2CPCh. 7.3 - Prob. 7.3CPCh. 7.3 - Prob. 7.4CPCh. 7.3 - What is array bounds checking? Does C++ perform...Ch. 7.3 - What is the output of the following code? int...Ch. 7.3 - The following program skeleton contains a...Ch. 7.3 - Define the following arrays: A) ages, a 10-element...Ch. 7.3 - Is each of the following a valid or invalid array...Ch. 7.6 - Given the following array definition: int values[]...
Ch. 7.6 - Given the following array definition: int nums[5]...Ch. 7.6 - Prob. 7.12CPCh. 7.6 - What is the output of the following code? (You may...Ch. 7.7 - Prob. 7.14CPCh. 7.7 - Prob. 7.15CPCh. 7.7 - When used as function arguments, are arrays passed...Ch. 7.7 - What is the output of the following program? (You...Ch. 7.7 - The following program skeleton, when completed,...Ch. 7.9 - Prob. 7.19CPCh. 7.9 - How many elements are in the following array?...Ch. 7.9 - Write a statement that assigns the value 56893.12...Ch. 7.9 - Prob. 7.22CPCh. 7.9 - Prob. 7.23CPCh. 7.9 - Fill in the table below so that it shows the...Ch. 7.9 - Write a function called displayArray7. The...Ch. 7.9 - A video rental store keeps DVDs on 50 racks with...Ch. 7.11 - Prob. 7.27CPCh. 7.11 - Write a definition statement for a vector named...Ch. 7.11 - Prob. 7.29CPCh. 7.11 - Write a definition statement for a vector named...Ch. 7.11 - Prob. 7.31CPCh. 7.11 - snakes is a vector of doubles, with 10 elements....Ch. 7 - Prob. 1RQECh. 7 - Look at the following array definition: int...Ch. 7 - Why should a function that accepts an array as an...Ch. 7 - Prob. 4RQECh. 7 - Prob. 5RQECh. 7 - Prob. 6RQECh. 7 - Prob. 7RQECh. 7 - Assuming that numbers is an array of doubles, will...Ch. 7 - Prob. 9RQECh. 7 - Prob. 10RQECh. 7 - How do you establish a parallel relationship...Ch. 7 - Prob. 12RQECh. 7 - When writing a function that accepts a...Ch. 7 - What advantages does a vector offer over an array?Ch. 7 - Prob. 15RQECh. 7 - The size declarator must be a(n) ________ with a...Ch. 7 - Prob. 17RQECh. 7 - Prob. 18RQECh. 7 - The number inside the brackets of an array...Ch. 7 - C++ has no array ________ checking, which means...Ch. 7 - Starting values for an array may be specified with...Ch. 7 - If an array is partially initialized, the...Ch. 7 - If the size declarator of an array definition is...Ch. 7 - By using the same _________ for multiple arrays,...Ch. 7 - Prob. 25RQECh. 7 - Prob. 26RQECh. 7 - To pass an array to a function, pass the ________...Ch. 7 - A(n) _______ array is like several arrays of the...Ch. 7 - Its best to think of a two-dimensional array as...Ch. 7 - Prob. 30RQECh. 7 - Prob. 31RQECh. 7 - When a two-dimensional array is passed to a...Ch. 7 - The ________________ is a collection of...Ch. 7 - The two types of containers defined by the STL are...Ch. 7 - The vector data type is a(n) ____________...Ch. 7 - Prob. 36RQECh. 7 - To store a value in a vector that docs nor have a...Ch. 7 - To determine the number of elements in a vector,...Ch. 7 - Use the _______________ member function to remove...Ch. 7 - To completely clear the contents of a vector, use...Ch. 7 - Prob. 41RQECh. 7 - Prob. 42RQECh. 7 - In a program, you need to store the identification...Ch. 7 - Prob. 44RQECh. 7 - In a program, you need to store the populations of...Ch. 7 - The following code totals the values in two...Ch. 7 - Prob. 47RQECh. 7 - Prob. 48RQECh. 7 - Prob. 49RQECh. 7 - Prob. 50RQECh. 7 - Prob. 51RQECh. 7 - T F The individual elements of an array are...Ch. 7 - T F The first element in an array is accessed by...Ch. 7 - Prob. 54RQECh. 7 - Prob. 55RQECh. 7 - T F Subscript numbers may be stored in variables.Ch. 7 - T F You can write programs that use invalid...Ch. 7 - Prob. 58RQECh. 7 - T F The values in an initialization list are...Ch. 7 - T F C++ allows you to partially initialize an...Ch. 7 - T F If an array is partially initialized, the...Ch. 7 - T F If you leave an element uninitialized, you do...Ch. 7 - T F If you leave out the size declarator of an...Ch. 7 - T F The uninitialized elements of a string array...Ch. 7 - T F You cannot use the assignment operator to copy...Ch. 7 - Prob. 66RQECh. 7 - T F To pass an array to a function, pass the name...Ch. 7 - T F When defining a parameter variable to hold a...Ch. 7 - T F When an array is passed to a function, the...Ch. 7 - T F A two-dimensional array is like several...Ch. 7 - T F Its best to think of two-dimensional arrays as...Ch. 7 - T F The first size declarator (in the declaration...Ch. 7 - T F Two-dimensional arrays may be passed to...Ch. 7 - T F C++ allows you to create arrays with three or...Ch. 7 - Prob. 75RQECh. 7 - T F To use a vector, you must include the vector...Ch. 7 - T F vectors can report the number of elements they...Ch. 7 - T F You can use the [ ] operator to insert a value...Ch. 7 - T F If you add a value to a vector that is already...Ch. 7 - int sixe; double values [size];Ch. 7 - Prob. 81RQECh. 7 - Prob. 82RQECh. 7 - Prob. 83RQECh. 7 - int numbers[8] ={1,2, , ,4, , 5};Ch. 7 - float ratings[] ;Ch. 7 - Prob. 86RQECh. 7 - Prob. 87RQECh. 7 - Prob. 88RQECh. 7 - void showValues(int nums [4][]) { For (rows = 0;...Ch. 7 - Prob. 90RQECh. 7 - Largest/Smallest Array Values Write a program that...Ch. 7 - Rainfall Statistics Write a program that lets the...Ch. 7 - Chips and Salsa Write a program that lets a maker...Ch. 7 - Larger than n In a program, write a function that...Ch. 7 - Monkey Business A local zoo wants to keep track of...Ch. 7 - Rain or Shine An amateur meteorologist wants to...Ch. 7 - Number Analysis Program Write a program that asks...Ch. 7 - Lo Shu Magic Square The Lo Shu Magic Square is a...Ch. 7 - Payroll Write a program that uses the following...Ch. 7 - Drivers License Exam The local Drivers License...Ch. 7 - Prob. 11PCCh. 7 - Grade Book A teacher has five students who have...Ch. 7 - Grade Book Modification Modify the grade book...Ch. 7 - Lottery Application Write a program that simulates...Ch. 7 - vector Modification Modify the National Commerce...Ch. 7 - World Series Champions If you have downloaded this...Ch. 7 - Name Search If you have downloaded this books...Ch. 7 - Tic-Tac-Toe Game Write a program that allows two...Ch. 7 - 2D Array Operations Write a program that creates a...Ch. 7 - Prob. 22PC
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
Write a version of the statcheck program in Figure 10.10, called fstatcheck that takes a descriptor number on t...
Computer Systems: A Programmer's Perspective (3rd Edition)
What ambiguity exists in the statement X = 3 + 2 5
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
The spreadsheet in Microsoft Excel file Ch01Ex01_U10e.xlsx contains records of employee activity on special pro...
Using MIS (10th Edition)
Give the name of the algorithm that results from each of the following special cases: a. Local beam search with...
Artificial Intelligence: A Modern Approach
Write SQL commands for the following: Create two different forms of the INSERT command to add a student with a ...
Modern Database Management
What is the output of the following cout statements embedded in these if-else statements? You are to assume tha...
Problem Solving with C++ (10th Edition)
Knowledge Booster
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.Similar questions
- Assume int[] t = {0, 1, 2, 3, 4, 5}; What is t[6]? undefined, there is an error in this code 4 6 5arrow_forward#include <stdio.h>#include <string.h>#define SIZE 6struct Student{char name[50];int id;float mark;};int Search1(char input[], struct Student data[]);int Search2(int input, struct Student data[]);int main() {char search_name[30];int search_id;int result1, result2;struct Student list[SIZE] = {{"Amylia", 544199, 75.4},{"Cheong", 143566, 92.3},{"Harry", 109774, 65.5},{"Krishnan", 334514, 86.7},{"Melissa", 257890, 55.4},{"Timothy",144656, 77.8}};printf("Enter Student Name: ");gets(search_name);result1 = Search1(search_name, list);//Answer for part (a)(ii) – Display the matching index of result1printf("Enter Student ID: ");scanf("%d",&search_id);result2 = Search2(search_id,list);//Answer for part (a)(iii)- Display the matching index of result2return 0;}//Answer for part (a)(i) – function definition for Search1//Answer for part (a)(iii) – function definition for Search2arrow_forwardchar[] b = {'a', 'b', 'c', '5'}; System.out.println(b.charAt(2)); displays an error occurs because b is not a variable of type String the character c the character barrow_forward
- char[] X = { ‘A’, ‘E’, ‘I’, ‘O’, ‘U’, ‘V’}; What is the value of X[2]? a.I b.E c.U d.Oarrow_forward#include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…arrow_forward#include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…arrow_forward
- #include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…arrow_forward#include <stdio.h>#include <stdlib.h> int MAX_SIZE = 10;int n = 0; //A counter variable which will keep track of number of elements in arr. void append(int *arr, int element){ if(n == MAX_SIZE) { MAX_SIZE = MAX_SIZE * 2; int *ptr = (int*)malloc(MAX_SIZE * sizeof(int)); //Copy elements of existing array to a new array for(int i=0;i<n;i++) { ptr[i] = arr[i]; } arr = ptr; n++; } arr[n] = element;} int get(int *arr, int index){ return arr[index];}int main(){ int *arr = (int*)malloc(MAX_SIZE * sizeof(int)); n = 10; for(int i=0;i<n;i++) arr[i] = i+1; printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n); printf("\nArray: "); for(int i=0;i<n;i++) printf("%d ", arr[i]); printf("\n\nAdding an element"); append(arr, 11); printf("\nArray size: %d", MAX_SIZE); printf("\nNumber of elements: %d", n);…arrow_forward#include <stdio.h>#include <string.h>#define SIZE 6struct Cake {char name[50];float price;};int searchChoice(char *choice, struct Cake data[]);void displayChoice(int index, struct Cake data[]);int main() {char choice[50];int index;//Answer for Part (i) – Declare and initialise array stockprintf("What is your choice of cake? ");gets(choice);index = searchChoice(choice, stock);displayChoice(index, stock);return 0;}//Answer for Part (ii) – Function definition for searchChoice//Answer for Part (iii) – Function definition for displayChoicearrow_forward
- char[ ] letters=new char[5];int x = 0;while(x < 10){ar[x]='a';x++;}arrow_forwardassume the following variable declaration: intg[]={4,5,2,1,7,12,9,3,29,10,13,43}; int[]q=new int[20]; write java statement to copy array g into the last portion of array q.arrow_forwardWhat is this code's purpose?$Error=[] ;arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- 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
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education
1.1 Arrays in Data Structure | Declaration, Initialization, Memory representation; Author: Jenny's lectures CS/IT NET&JRF;https://www.youtube.com/watch?v=AT14lCXuMKI;License: Standard YouTube License, CC-BY
Definition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License