Starting Out With C++: Early Objects (10th Edition)
10th Edition
ISBN: 9780135235003
Author: Tony Gaddis, Judy Walters, Godfrey Muganda
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Textbook Question
Chapter 8.3, Problem 8.6CP
What is the output of the following code?
int values[5], count;
for (count= O; count< 5; count+ +)
values[count] =count+ 1;
for (count= O; 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
int a[ 10] = {1,5,3,8,4,2,6,9,7};
int *p;
p = &a[2];
p[0] = 10;
p[1] = 15;
What are the values of a?
Select one:
O a. {10,15,3,8,4,2,6,9,7}
O b. {1,15,10,8,4,2,6,9,7}
O c. {1,5,10,15,4,2,6,9,7}
O d. {1,10,15,8,4,2,6,9,7}
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
False
#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));
}
Chapter 8 Solutions
Starting Out With C++: Early Objects (10th Edition)
Ch. 8.3 - Define the following arrays: A) empNum, a 100...Ch. 8.3 - Prob. 8.2CPCh. 8.3 - Prob. 8.3CPCh. 8.3 - Assume a program includes the following two...Ch. 8.3 - What is array bounds checking? Does C++ perform...Ch. 8.3 - What is the output of the following code? int...Ch. 8.3 - Complete the following program skeleton so it will...Ch. 8.7 - Define the following arrays: A) ages, a 10-element...Ch. 8.7 - Indicate if each of the following array...Ch. 8.7 - Prob. 8.10CP
Ch. 8.7 - Given the following array definition: int values...Ch. 8.7 - Prob. 8.12CPCh. 8.7 - Prob. 8.13CPCh. 8.7 - What is the output of the following code? const...Ch. 8.9 - Write a typedef statement that makes the name...Ch. 8.9 - Prob. 8.16CPCh. 8.9 - What is the output of the following program...Ch. 8.9 - The following program segments, when completed,...Ch. 8.11 - Prob. 8.19CPCh. 8.11 - Prob. 8.20CPCh. 8.11 - Prob. 8.21CPCh. 8.11 - Prob. 8.22CPCh. 8.11 - Prob. 8.23CPCh. 8.11 - Fill in the empty table below so it shows the...Ch. 8.11 - Write a function called displayArray7. The...Ch. 8.11 - Prob. 8.26CPCh. 8.12 - Prob. 8.27CPCh. 8.12 - Write definition statements for the following...Ch. 8.12 - Define gators to be an empty vector of ints and...Ch. 8.13 - True or false: The default constructor is the only...Ch. 8.13 - True or false: All elements in an array of objects...Ch. 8.13 - What will the following program display on the...Ch. 8.13 - Complete the following program so that it defines...Ch. 8.13 - Add two constructors to the Product structure...Ch. 8.13 - Prob. 8.35CPCh. 8.13 - Prob. 8.36CPCh. 8.13 - Prob. 8.37CPCh. 8.13 - Write the definition for an array of five Product...Ch. 8.13 - Write a structure declaration called Measurement...Ch. 8.13 - Write a structure declaration called Destination ,...Ch. 8.13 - Define an array of 20 Destination structures (see...Ch. 8 - The ________ indicates the number of elements, or...Ch. 8 - The size declarator must be a(n) _______ with a...Ch. 8 - Prob. 3RQECh. 8 - Prob. 4RQECh. 8 - The number inside the brackets of an array...Ch. 8 - C++ has no array ________ checking, which means...Ch. 8 - Prob. 7RQECh. 8 - If a numeric array is partially initialized, the...Ch. 8 - If the size declarator of an array definition is...Ch. 8 - Prob. 10RQECh. 8 - Prob. 11RQECh. 8 - Prob. 12RQECh. 8 - Arrays are never passed to functions by _______...Ch. 8 - To pass an array to a function, pass the ________...Ch. 8 - A(n) ________ array is like several arrays of the...Ch. 8 - Its best to think of a two -dimensional array as...Ch. 8 - Prob. 17RQECh. 8 - Prob. 18RQECh. 8 - When a two -dimensional array is passed to a...Ch. 8 - When you pass the name of an array as an argument...Ch. 8 - Look at the following array definition. int values...Ch. 8 - Given the following array definition: int values...Ch. 8 - Prob. 23RQECh. 8 - Assume that array1 and array2 are both 25-element...Ch. 8 - Prob. 25RQECh. 8 - How do you establish a parallel relationship...Ch. 8 - Look at the following array definition. double...Ch. 8 - Prob. 28RQECh. 8 - Prob. 29RQECh. 8 - Prob. 30RQECh. 8 - Prob. 31RQECh. 8 - The following code totals the values in each of...Ch. 8 - In a program you need to store the identification...Ch. 8 - Prob. 33RQECh. 8 - Prob. 34RQECh. 8 - Prob. 36RQECh. 8 - Prob. 37RQECh. 8 - Prob. 38RQECh. 8 - Each of the following functions contains errors....Ch. 8 - Soft Skills Diagrams are an important means of...Ch. 8 - Perfect Scores 1. Write a modular program that...Ch. 8 - Larger Than n Create a program with a function...Ch. 8 - Roman Numeral Converter Write a program that...Ch. 8 - Chips and Salsa Write a program that lets a maker...Ch. 8 - Monkey Business A local zoo wants to keep track of...Ch. 8 - Rain or Shine An amateur meteorologist wants to...Ch. 8 - Lottery Write a program that simulates a lottery....Ch. 8 - Rainfall Statistics Write a modular program that...Ch. 8 - Lo Shu Magic Square The Lo Shu Magic Square is a...Ch. 8 - Baseball Champions This challenge uses two files...Ch. 8 - Chips and Salsa Version 2 Revise Programming...Ch. 8 - Stats Class and Rainfall Statistics Create a Stats...Ch. 8 - Stats Class and Track Statistics Write a client...Ch. 8 - Prob. 14PCCh. 8 - Drivers License Exam The State Department of Motor...Ch. 8 - Array of Payro11 Objects Design a PayRoll class...Ch. 8 - Drink Machine Simulator Create a class that...Ch. 8 - Bin Manager Class Design and write an object...Ch. 8 - Tic-Tac-Toe Game Write a modular program that...Ch. 8 - Theater Ticket Sales Create a TicketManager class...
Additional Engineering Textbook Solutions
Find more solutions based on key concepts
While a program is running, a control is said to lose focus when the focus moves from that control to another c...
Introduction To Programming Using Visual Basic (11th Edition)
Write a statement that defines an empty vector object named avect that can hold strings.
Starting Out with C++ from Control Structures to Objects (9th Edition)
Suppose an application contains a structure named Engine and that motor1 and motor2 are instances of the Engine...
Starting out with Visual C# (4th Edition)
3.12 (Date Create a class called Date that includes three pieces Of information as data
members—a month (type ...
C++ How to Program (10th Edition)
Write an SQL statement to display the breed, type, and DOB for all pets having the type Dog and the breed Std. ...
Database Concepts (7th Edition)
Trace the operation of A search applied to the problem of getting to Bucharest from Lugoj using the straight-li...
Artificial Intelligence: A Modern Approach
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
- #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 brieflyarrow_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 using namespace std; void some_action_1(int); int main() { cout<arrow_forward#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;}arrow_forward#include <stdio.h> struct Single { int num; }; void printSingle(int f) { int binaryNum[33]; int i = 0; while(f>0) { binaryNum[i] = f % 2; f = f/2; i++; } for (int j=i-1; j>= 0; j--) { printf("%d",binaryNum[j]); } } int main() { struct Single single; single.num = 33; printf("Number: %d\n",single.num); printSingle(single.num); return 0; }arrow_forwardQ1/ find code optimization of this code then find type to this code. for (i=1;iarrow_forward#include<iostream>using namespace std;void main(){double pi = 0, denominator = 1;int counter = 999999;for (int x = 0; x < counter; x++){if (x % 2 != 0){pi = pi - (1 / denominator);}else{pi = pi + (1 / denominator);}denominator = denominator + 2;}pi = pi * 4;cout << " So the computed value of a PI is = " << pi << endl;cout << " ";//return 0;system("pause");} Note: This a program called ComputePI to compute the value of π Tutor just have to Modify This program to use nested-if (if ... else if ... else if ... else) instead. Explain by applying a double line commentarrow_forwardint sum = 0; for (int i 0; i < 5; i++){ sum += i; } cout << sum;arrow_forward#include using namespace std; int find(int arr[], int value, int left, int right) { int midpt = (left+right)/2; if (left > right) return -1; if ( arr[midpt] return midpt; else if (arr[midpt] < value) == value) return else return find(arr,value, left,midpt-1); } void main(void) { int arr[] ={4,5,6,9,11}; cout<arrow_forwardMay you please explain why the result is truck?arrow_forward#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 mearrow_forwarddouble tab1[5] = {2,3,4,5,6}; double tab2[5] = {6,5,4,3,2}; for(int i = 0;i<5;i++) { tab1[i] = tab1[i]*tab2[i]; cout<<tab1[i]<<" "; } 12 15 16 15 16 15 15 16 15 12 12 15 16 15 12 12 15 12 15 12arrow_forwardarrow_back_iosSEE MORE QUESTIONSarrow_forward_iosRecommended 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 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:PEARSONC 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 Education1.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-BYDefinition of Array; Author: Neso Academy;https://www.youtube.com/watch?v=55l-aZ7_F24;License: Standard Youtube License