Starting Out with C++ from Control Structures to Objects (8th Edition)
8th Edition
ISBN: 9780133769395
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>#include <stdlib.h>
typedef struct Number_struct { int num;} Number;
void Swap(Number* numPtr1, Number* numPtr2) { /* Your code goes here */}
int main(void) { Number* num1 = NULL; Number* num2 = NULL;
num1 = (Number*)malloc(sizeof(Number)); num2 = (Number*)malloc(sizeof(Number));
int int1; int int2;
scanf("%d", &int1); scanf("%d", &int2);
Thank you so much but i forgot to put this how i would fit in into this.
num1->num = int1; num2->num = int2;
Swap(num1, num2); printf("num1 = %d, num2 = %d\n", num1->num, num2->num);
return 0;}
#include <stdio.h>#include <string.h>
int findRepeat(char* s){int p , i , j;
p = -1;
for (i = 0 ; i < strlen(s) ; i++){for (j = i + 1; j < strlen(s); j++){if (s[i] == s[j]){p = i;break;}}if (p != -1)break;}return p;}
int main(){char str[] = "Hello World";int pos = findRepeat(str);if (pos == -1)printf("Not found");elseprintf("%c", str[pos]);return 0;}can you please explain this code for me
#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 Search2
Chapter 7 Solutions
Starting Out with C++ from Control Structures to Objects (8th 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.7 - Given the following array definition: int values[]...Ch. 7.7 - Given the following array definition: int nums[5]...Ch. 7.7 - Prob. 7.12CP
Ch. 7.7 - What is the output of the following code? (You may...Ch. 7.8 - Prob. 7.14CPCh. 7.8 - Prob. 7.15CPCh. 7.8 - When used as function arguments, are arrays passed...Ch. 7.8 - What is the output of the following program? (You...Ch. 7.8 - The following program skeleton, when completed,...Ch. 7.10 - Prob. 7.19CPCh. 7.10 - How many elements are in the following array?...Ch. 7.10 - Write a statement that assigns the value 56893.12...Ch. 7.10 - Prob. 7.22CPCh. 7.10 - Prob. 7.23CPCh. 7.10 - Fill in the table below so that it shows the...Ch. 7.10 - Write a function called displayArray7. The...Ch. 7.10 - A video rental store keeps DVDs on 50 racks with...Ch. 7.12 - Prob. 7.27CPCh. 7.12 - Write a definition statement for a vector named...Ch. 7.12 - Prob. 7.29CPCh. 7.12 - Write a definition statement for a vector named...Ch. 7.12 - Prob. 7.31CPCh. 7.12 - 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 - 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. 20PC
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
- char[] 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_forwardThe following code will display 150: { int a[] = { 10,20,30,40,50 }; int sum = 0; for (int i = 0; i <= 4;i++ ) sum += a[--i]; cout << sum; Select one: True Falsearrow_forwardWhat the following code does? int * foo = new int [5]; if (!foo) { ..}arrow_forward
- int grades[100]; int i; for (i=0;i <= 100;i++) { grades[i) = 100; } The above C++ code is the proper way to initialize the grades array, TRUE or FLASE True Falsearrow_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#include <iostream> #include <ctime> #include <cmath> const int MAX = 1000; const char CLASS[] = {'A','B','C'}; struct Points{ int x,y; char c; double dist(Points q){ return sqrt(pow(x-q.x,2)+pow(y-q.y,2)); } }; int main(){ return 0; } int main(){ srand(time(0)); }arrow_forward
- What is the purpose of this code$Error=[] ;arrow_forward#include<stdio.h>#include<string.h>struct info{char names[100];int age;float wage;};int main(int argc, char* argv[]) {int line_count = 0;int index, i;struct info hr[10];if (argc != 2)printf("Invalid user_input!\n");else {FILE* contents = fopen (argv[1], "r");struct info in;if (contents != NULL) {printf("File has been opened successfully.\n\n");while (fscanf(contents, "%s %d %f\n",hr[line_count].names, &hr[line_count].age, &hr[line_count].wage) != EOF) {printf("%s %d %f\n", hr[line_count].names, hr[line_count].age, hr[line_count].wage);line_count++;}printf("\nTotal number of lines in document are: %d\n\n", line_count);fclose(contents);printf("Please enter a name: ");char user_input[100];fgets(user_input, 30, stdin);user_input[strlen(user_input)-1] = '\0';index = -1;for(i = 0; i < line_count; i++){if(strcmp(hr[i].names, user_input) == 0){index = i;break;}}if(index == -1)printf("Name %s not found\n", user_input);else{while(fread(&in, sizeof(struct info), 1,…arrow_forwardc++ coding language I need help with part B and C please. If you are unable to do both, then PLEASE prioritize part C. I am really stuck and really can use the help. This is the code for c that was provided in order to guide me: const int N =31; // N parking spaces bool parking[N]; // the garage void EmptyTheLot(bool parking[], int N) { for(int i=0; i<N; i++) p[i]=false; // empty space } // returns -1 if no space found, //otherwise it returns 0<=i<N for a valid space. int FindSpace(int PlateNumber, bool parking[], int N) { // ????? } main() { EmptyTheLot(parking, N); // start with an empty parking garage. // get plate numbers and fill lot. }arrow_forward
- #include<stdio.h>#include<stdlib.h>#include<string.h>/* function that converts the change into count of 50,20,10,5 and stores the count in changeArray*/int coinChange(int changeArray[10][4],int index,int change){int count50=0,count20=0,count10=0,count5=0;while(change > 0){if(change > 0 && change <=95 && change% 5 == 0){if(change >= 50){change -= 50;count50++;}else if(change >= 20){change -= 20;count20++;}else if(change>=10){change -= 10;count10++;}else if(change>=5){change -= 5;count5++;}}}changeArray[index][0]=count50;changeArray[index][1]=count20;changeArray[index][2]=count10;changeArray[index][3]=count5;return change;}/* function that reads 'coins.txt' and stores names in names array, coin values in coins array, compute change and stores change count in change array */int readFromFile(char names[10][100],int coins[],int change[10][4]){int index=-1,i=0;FILE *fp;fp=fopen("coins.txt","r");if(fp==NULL){printf("File doesnot…arrow_forward#include <iostream>#include <string.h>using namespace std;int index1(char *T,char *P){int t=0,p=0,i,j,r;t = strlen(T);p = strlen(P);i=0;int max = t - p + 1;while(i<max){for(j=0;j<p;j++){if(P[j]==T[i+j]){r = i;break;}else r = -1;}i++;}return r;} int main(){ int l;char c[100];char d[100];cout<<"Enter First String\n"; cin>>c;cout<<"Enter Second String\n";cin>>d;l = index1(c,d);cout<<l; return 0;} Note: Remove Funcationarrow_forward#include <iostream> #include <string.h> using namespace std; int index1(char *T,char *P) { int t=0,p=0,i,j,r; t = strlen(T); p = strlen(P); i=0; int max = t - p + 1; while(i<max) { for(j=0;j<p;j++) {if(P[j]==T[i+j]) {r = i; break; } else r = -1; } i++; } return r; } int main() { int l; char c[50]; char d[50]; cout<<"Enter First String\n"; cin>>c; cout<<"Enter Second String\n"; cin>>d; l = index1(c,d); cout<<"The returned index is:"<<l; return 0; }Note:Remove Funcationarrow_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