Problem Solving with C++ (10th Edition)
10th Edition
ISBN: 9780134448282
Author: Walter Savitch, Kenrick Mock
Publisher: PEARSON
expand_more
expand_more
format_list_bulleted
Question
Chapter 7.4, Problem 20STE
Program Plan Intro
Purpose of given code:
The purpose of given code is to store the values in multidimensional array and print these values.
Given code:
/*Include the appropriate headers*/
#include<iostream>
using namespace std;
//Main method
int main()
{
/*Declaration of variables*/
int myArray[4][4], index1, index2;
/*Loop for rows*/
for (index1 = 0; index1 < 4; index1++)
/*Loop for columns*/
for (index2 = 0; index2 < 4; index2++)
/*Assign the values into array*/
myArray[index1][index2] = index2;
/*Loop for rows*/
for (index1 = 0; index1 < 4; index1++)
{
/*Loop for columns*/
for (index2 = 0; index2 < 4; index2++)
/*Print statement with values*/
cout << myArray[index1][index2] << " ";
//Print statement
cout << endl;
}
}
Expert Solution & Answer
Want to see the full answer?
Check out a sample textbook solutionStudents have asked these similar questions
typedef struct node_t node_t;
struct node_t {
};
int32_t value;
node_t* next;
node_t* insert (node_t* list, int32_t v, int32_t* flag);
3) As you may have noticed from MT1, Howie is lazy. He wants you to write the interface
for the following implementation of function copy_to_linked_list. He really appreciates your help!
/* copy_to_linked_list
int32_t copy_to_linked_list (int32_t a[], int32_t size, node_t** list_p) {
int32_t flag, i;
for (i = 0; i < size; ++i) {
*list_p = insert (*list_p, a[i], &flag);
if (-1== flag)
return -1;
}
return 0;
Describe what the following code is doing/calculating:
def drop_uninformative_objects(X, y):# your code herereturn X_subset, y_subset
# TEST drop_uninformative_objects functionA = pd.DataFrame(np.array([[0, 3, np.nan],[4, np.nan, np.nan],[np.nan, 6, 7],[np.nan, np.nan, np.nan],[5, 5, 5],[np.nan, 8, np.nan],]))b = pd.Series(np.arange(6))A_subset, b_subset = drop_uninformative_objects(A, b)
assert A_subset.shape == (3, 3)assert b_subset.shape == (3,)
Chapter 7 Solutions
Problem Solving with C++ (10th Edition)
Ch. 7.1 - Prob. 1STECh. 7.1 - In the array declaration double score(5); state...Ch. 7.1 - Identity any errors in the following array...Ch. 7.1 - What is the output of the following code? char...Ch. 7.1 - What is the output of the following code? double a...Ch. 7.1 - What is the output of the following code? int i,...Ch. 7.1 - Prob. 7STECh. 7.1 - Suppose we expect the elements of the array a to...Ch. 7.1 - Prob. 9STECh. 7.1 - Suppose you have the following array declaration...
Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Prob. 12STECh. 7.2 - Write a function definition for a function called...Ch. 7.2 - Consider the following function definition: void...Ch. 7.2 - Insert const before any of the following array...Ch. 7.2 - Write a function named outOfOrder that takes as...Ch. 7.3 - Write a program that will read up to ten...Ch. 7.3 - Write a program that will read up to ten letters...Ch. 7.3 - Following is the declaration for an alternative...Ch. 7.4 - Prob. 20STECh. 7.4 - Write code that will fill the array a (declared...Ch. 7.4 - Prob. 22STECh. 7 - Write a function named firstLast2 that takes as...Ch. 7 - Write a function named countNum2s that takes as...Ch. 7 - Write a function named swapFrontBack that takes as...Ch. 7 - The following code creates a small phone book. An...Ch. 7 - There are three versions of this project. Version...Ch. 7 - Hexadecimal numerals are integers written in base...Ch. 7 - Solution to Programming Project 7.3 Write a...Ch. 7 - Prob. 4PPCh. 7 - Write a program that reads in a list of integers...Ch. 7 - Prob. 6PPCh. 7 - An array can be used to store large integers one...Ch. 7 - Write a program that will read a line of text and...Ch. 7 - Write a program to score five-card poker hands...Ch. 7 - Write a program that will allow two users to play...Ch. 7 - Write a program to assign passengers seats in an...Ch. 7 - Prob. 12PPCh. 7 - The mathematician John Horton Conway invented the...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - Redo (or do for the first time) Programming...Ch. 7 - A common memory matching game played by young...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Your swim school has two swimming instructors,...Ch. 7 - Prob. 19PPCh. 7 - The Social Security Administration maintains an...
Knowledge Booster
Similar questions
- ANSWER THIS QUESTION Why should the **head in insert_atFront function has two asterisk (*)? Why should the searchNode return a pointer?arrow_forwardAssuming buf is a valid pointer, what is the problem in the code below? What would be an alternate way of implementing this that would avoid the problem? size_t sz = buf->size(); while ( --sz >= 0 ) { /* do something */ }arrow_forwardWhat is a way to safely dereference a pointer?arrow_forward
- Please check the instructions on the images given. Sample output are also given on the image while the code for modification is provided below. hash.c #include <stdlib.h>#include <stdio.h> struct Node { int val; struct Node * next;}; struct HashTable { int size; struct Node ** table;}; struct Node * create_node(int val);struct HashTable * create_table(int size);void destroy_table(struct HashTable * h);void display_table(struct HashTable *h);int hash_function(int key, int size);void insert(struct HashTable *h, int val);int search(struct HashTable * h, int val);struct Node * delete(struct HashTable * h, int val); void main(){struct HashTable * h = create_table(8);display_table(h); int val_insert[12] = {12, 31, 45, 83, 72, 29, 84, 39, 61, 24, 10, 50}; for (int i=0; i<12; i++) { insert(h,val_insert[i]);}display_table(h); int val_search[4] = {29, 99, 72, 20};for (int i=0; i<4; i++) { int result = search(h,val_search[i]); printf("Search value %2d:…arrow_forwardswap_nums seems to work, but not swap_pointers. Fix it. #include <stdio.h>void swap_nums(int *x, int *y) { int tmp; tmp = *x; *x = *y; *y = tmp; } void swap_pointers(char *x, char *y) { char *tmp; tmp = x; x = y; y = tmp; } int main() { int a,b; char *s1,*s2; a = 3; b=4; swap_nums(&a,&b); printf("a is %d\n", a); printf("b is %d\n", b); s1 = "I should print second"; s2 = "I should print first"; swap_pointers(s1,s2); printf("s1 is %s\n", s1); printf("s2 is %s\n", s2); return 0; }arrow_forward10. write code in c++arrow_forward
- In C++arrow_forwardin c, how to pass the values of d array to the void DisplayImage function and print the elements of that array one by one using pointers defined in the functionarrow_forwardConsider the following code snippet: vector num (3) ; num [0] = 1; num [1] = 2; num [2] = 3; num.pop_back(); Which element or elements of the vector are removed by the pop_back() function in the given code snippet? The element with index 0 The element with index 1 The element with index 2 All the elementsarrow_forward
- please solve both questionsarrow_forwardIN C PROGRAMMING LANGUAGE: Please write a pointer version of squeeze() named psqueeze(char *s, char c) which removes c from the string s.arrow_forwardWrite code in c++ and add comments too with the code Note: must add the comments and attach output too Thanksarrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- New Perspectives on HTML5, CSS3, and JavaScriptComputer ScienceISBN:9781305503922Author:Patrick M. CareyPublisher:Cengage Learning
New Perspectives on HTML5, CSS3, and JavaScript
Computer Science
ISBN:9781305503922
Author:Patrick M. Carey
Publisher:Cengage Learning