C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN: 9781337102087
Author: D. S. Malik
Publisher: Cengage Learning
expand_more
expand_more
format_list_bulleted
Question
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by stepSolved in 2 steps
Knowledge Booster
Similar questions
- Task - Using pointers to process arrays (C Language) Example #5 below expected output is 45, but from the program below its coming out to 46. Please help make it come out to 45 as expected In a TV show, each minute can be either interesting or boring. Assume that if 7 consecutive minutes are boring, then an average viewer will stop watching the show. Write a C program that calculates how many minutes that an average viewer will watch a TV show, given the interesting minutes. Assume the TV shows are 45 minutes long. Requirements Name your program project4_minutes.c. Follow the format of the examples below. The program will read in the number of interesting minutes, then read in the interesting minutes. The program should include the following function. Do not modify the function prototype. int find_minute(int *minutes, int n); minutes represents the input array for interesting minutes, n is the length of the array (the number of interesting minutes). The function returns the how…arrow_forwardDeal or No Deal? Code in C languagearrow_forwardc++ program write a recursive function to find the factorial of a number. main points : 1) n and r are stored in two parallel arrays. 2) you have to read the arrays n and r at run time. 3) compute nCr for each corresponding terms in the array n and r and display it properly formatted 4) also in the program you should print the current date and time using the library functionsarrow_forward
- Language: C/C++ Q.1 - Write an algorithm that takes an array of characters, with only the characters 1, 2 and only two occurrences of the character 0, and the size of the array that has filled (valid) characters. This algorithm must check that the string that is stored is of the form x0y0x, where x is the inverse of y. (if x= "12221122", y="22112221"). The algorithm must use the Stack functions (create, pop, push, destroy, isempty) Q.2 - Write an algorithm for the Pune operation, which punishes an element on a stack by pushing it back n positions. Assume that the stack is implemented as a simply chained linear list. Pune (Pilha *p, int n); Q.3 - Write an algorithm that punishes the first element of a row represented in a circular vector, taking it out of the first position and placing it in the middle of the row.P.S: It cannot perform calls to the Insert and Remove function from the queue, the algorithm must perform the operation only with vector manipulation. void…arrow_forward1)Please do it in C++ languagearrow_forwardQ1) Write a recursive function in C to check palindrome array. Example: arr[] = {2,1,1,1,2}; This is a palindrome array arr[] = {'a', 'b', 'b', 'a'}; This is a palindrome array Arr[] = {1,5,4,3,2}; This is not a palindrome array Plz solve this question in C programing language Q2) Write a recursive function for each case: 1.2D array rows and column swapping 2.2D array shifting. 3.2D array transposearrow_forward
- Matrix Problem Code this in C Write a program that reads two matrices of integers. It then generates the sum, difference, and product of the two matrices. The sum of the two matrices of the same size is a matrix with elements that are the sums of the corresponding elements of the two given matrices. Addition is not defined for matrices of different sizes. If A and B are matrices of the same size, then we define subtraction as follows: A – B = A + (-B). Thus, to subtract matrix B from matrix A, we simply subtract corresponding elements. To multiply a matrix by another matrix we need to do the "dot product" of rows and columns. The "Dot Product" is where we multiply matching members, then sum up: (1, 2, 3) • (7, 9, 11) = 1×7 + 2×9 + 3×11 = 58 We match the 1st members (1 and 7), multiply them, likewise for the 2nd members (2 and 9) and the 3rd members (3 and 11), and finally sum them up. Use the following definitions:#define ROW 6#define COL 6void add(int matrixResult[][COL],int…arrow_forwardC++ #include <iostream> #include <vector> using namespace std; //Todo4: Add cout statement to MergeSort () to print out // a line for each time this function is called, show the parameter // a line for each time we return from this function, show the parameter //Todo3: add a global variable to keep track // frequency of copy operation (marked below), and comparison operation (marked below) /* sort the vector into ascending order @param list: the vector of int to be sorted @pre-condiction: list has been initialized with some data @post-condition: the integers stored in list are rearranged into ascending order */ void MergeSort (vector<int> & list) { if (list.size()==1) return; //general case: divide and conquer //divide part int n=list.size(); int mid = (0+n-1)/2; //averge of first and last index vector<int> leftHalf(list.begin(),list.begin()+mid+1); // range constructor: initilize with elements from a range of existing vector: // from first iterator…arrow_forwardc++problemarrow_forward
- computer programing (C++) i need to get an algorithm ( flowchart and pseudocode) #include<iostream> //header file using namespace std; float function1(float, float[]); //function prototype for function1 float function2(float, float[]); //function prototype for function2 float function3(float[], float[]); //function prototype for function3 int function4( ); int main( ) //main function { float vin, R[4], i[4], v[4]; //declare float variables which are R,i and v int choice; //declare int variables for choice cout<<"Enter vin: \n"; //ask user for enter vin cin>>vin; //read the input cout<<"Enter R1, R2, R3: \n"; //ask the user enter value R1,R2, and R3 cin>>R[1]>>R[2]>>R[3]; //read input cout<<"Select from the menu: \n"; //ask user to select the menu…arrow_forwardDesign and write a C program that performs the following functionality:1. Prompt the user to enter a vector of maximum 10 digits. Note: the vector entered cancontain spaces.2. Read and store the vector that can contain spaces.3. Use a recursive function to transpose the vector from a row vector to a column vector.4. For example, if the user is prompted and enters the following in the command line(italicized and in red):Enter a vector of maximum 10 digits between 0 and 9: 1 2 3 4 55. Write a recursive function that will produce the following output (in blue):123456. Write and compile your codearrow_forwardMULTIPLE FUNCTIONS AND RECURSIVE FUNCTIONS Use #include<stdio.h>arrow_forward
arrow_back_ios
SEE MORE QUESTIONS
arrow_forward_ios
Recommended textbooks for you
- C++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning