Consider the below code. #include using namespace std; class Count { public: int count; }; Count(int c) { count C; } Count() { } count = 0; void increment (Count c, int times) { c.count++; times++; } int main() { } Count myCount; int times 0; - for (int i = 0; i < 100; i++) increment (myCount, times); cout << "myCount.count is << myCount. cout << times is << times; return 0; ** a. What is the printout of the above code? b. If the highlighted code above is changed to void increment(Count& c, int times) what will be the printout? . If the highlighted code above is changed to void increment(Count& c, int& times) what will be the printout? d. Can you change the highlighted code above to the following? void increment(const Count& c, int times)
Q: class TenNums { private: int *p; public: TenNums
A: Dear Student, The answer to your question is given below -
Q: #include "list.h" #include #include #include using namespace std; class ArrayList : public List…
A: #include "list.h" // (header file) #include <cstdlib>…
Q: Copy the completed Assignment 1 to Assignment 2. Re-label comments as needed. Add this feature to…
A: The complete code is given below with output .
Q: snack.h #include #include #include class Snack{ public: Snack(std::string, float, bool); int…
A: Algorithm:Define a Snack class with private attributes (name_, price_, expr_).Include setter methods…
Q: Q1: given N numbers in pl,p2,p3...pn, we would like to sort these number. The only process we can do…
A: C++ implementation is given below
Q: fix the getIndex function
A: Step 1: To fix the getIndex function make the following changes to function. template <typename…
Q: C++ Program #include #include #include using namespace std; int getData() { return…
A: Actually, program is a executable software that runs on a computer.
Q: b[2] A. int В. ВОХ x.n a[2].a C. pointer to pointer to char p.n D. char x.args[3] E. int pointer v…
A: The question is on match the correct option.
Q: Please Explain this code: #include #include using namespace std; int main() { int size =…
A: C ++ code to find standard deviation and mean is explained with output
Q: #include #include #include class Snack{ public: Snack(std::string, float, bool); int…
A: Class Definition:Establish a class named "Snack" encapsulating private attributes such as name,…
Q: C++ problem #include #include using namespace std; class node { public: string data;…
A: Here, you need to write code for 3 functions called printList(), removeLast() and addBack(). In…
Q: #include using namespace std; struct Triple { int row, col, value; }; class Matrix; class…
A: Matrix : Matrix in C++ contains rows and columns to solve various problems like solving…
Q: ++ Struct Pointers Help: I have a file called names.txt. Write a program that reads each line and…
A: Please find the answer below :
Q: Develop a C++ "doubly" linked list class of your own that can hold a series of signed shorts…
A: DoublyLinkedList Class:Define a private nested Node struct/class within the DoublyLinkedList class,…
Q: In C++ Syntax for arrays of objects classGrades allCS[15]; //the default constructor is…
A: Below is the required code in C++ :
Q: Pointers There follows a program with headers omitted. However, a question mark needs to be replaced…
A: According to the information given:- We have to find out the value of ? on the basic of output we…
Q: #include #include #include class Snack{ public: Snack(std::string, float, bool); int…
A: The following are steps needs to be taken for the required function:We ask the float value price…
Q: #include int arrC[10] = {0}; int bSearch(int arr[], int l, int h, int key);
A:
Q: Using the code source screenshot (C++) explain in depth what each line of code does.
A: #include <iostream>#include <cstdlib>using namespace std;// this is node struct with…
Trending now
This is a popular solution!
Step by step
Solved in 5 steps
- This C++ program keeps giving me the wrong median. #include <iostream> using namespace std; double median_value(int* arrptr, int n); class Median { private: int* array; int n; public: void getSizeArray(); void getNumElements(); void displayMedian(); ~Median() { delete[] array; } }; void Median::getSizeArray() { cout << "How big is array?"; cin >> n; } void Median::getNumElements() { array = new int[20]; for (int i = 0; i < n; i++) { cout << "How much "; cin >> *(array + i); } } void Median::displayMedian() { int m = median_value(array, n); cout << m; } int main() { Median showMedian; showMedian.getSizeArray(); showMedian.getNumElements(); showMedian.displayMedian(); return 0; } double median_value(int* arrptr, int n) { double median; if (n % 2 == 0) { median = (*(arrptr + (n / 2)) + *(arrptr + (n / 2 +1))) / 2; } else { //(arrptr[i]+(n/2)) median = *(arrptr + (n / 2)); } return median; }#include <iostream> #include <iostream> using namespace std; class Fraction { public: int numerator; int denominator; void set(int n, int d); void print(); Fraction multipliedBy(Fraction f); Fraction dividedBy(Fraction f); Fraction addedTo(Fraction f); Fraction subtract(Fraction f); bool isEqualTo(Fraction f); }; void Fraction::set(int n, int d) { numerator = n; denominator = d; } void Fraction::print() { cout << numerator << "/" << denominator; } Fraction Fraction::multipliedBy(Fraction f) { Fraction results; results.numerator = this -> numerator * f.numerator; results.denominator = this -> denominator * f.denominator; return results; } Fraction Fraction::dividedBy(Fraction f) { Fraction results; results.numerator = this -> numerator * f.denominator; results.denominator = this -> denominator * f.numerator; return results; } Fraction Fraction::addedTo(Fraction f) { Fraction results; results.numerator = (this ->…#include using namespace std; void some_action_1(int); int main() { cout<Q1 #include <stdio.h> int arrC[10] = {0}; int bSearch(int arr[], int l, int h, int key); int *joinArray(int arrA[], int arrB[]) { int j = 0; if ((arrB[0] + arrB[4]) % 5 == 0) { arrB[0] = 0; arrB[4] = 0; } for (int i = 0; i < 5; i++) { arrC[j++] = arrA[i]; if (arrB[i] == 0 || (bSearch(arrA, 0, 5, arrB[i]) != -1)) { continue; } else arrC[j++] = arrB[i]; } for (int i = 0; i < j; i++) { int temp; for (int k = i + 1; k < j; k++) { if (arrC[i] > arrC[k]) { temp = arrC[i]; arrC[i] = arrC[k]; arrC[k] = temp; } } } for (int i = 0; i < j; i++) { printf("%d ", arrC[i]); } return arrC; } int bSearch(int arr[], int l, int h, int key) { if (h >= l) { int mid = l + (h - l) / 2; if…C++ Program #include <iostream>#include <cstdlib>#include <ctime>using namespace std; int getData() { return (rand() % 100);} class Node {public: int data; Node* next;}; class LinkedList{public: LinkedList() { // constructor head = NULL; } ~LinkedList() {}; // destructor void addNode(int val); void addNodeSorted(int val); void displayWithCount(); int size(); void deleteAllNodes(); bool exists(int val);private: Node* head;}; // function to check data exist in a listbool LinkedList::exists(int val){ if (head == NULL) { return false; } else { Node* temp = head; while (temp != NULL) { if(temp->data == val){ return true; } temp = temp->next; } } return false;} // function to delete all data in a listvoid LinkedList::deleteAllNodes(){ if (head == NULL) { cout << "List is empty, No need to delete…#include <iostream>using namespace std;double median(int *, int);int get_mode(int *, int);int *create_array(int);void getinfo(int *, int);void sort(int [], int);double average(int *, int);int getrange(int *,int);int main(){ int *dyn_array; int students; int mode,i,range;float avrg;do{cout << "How many students will you enter? ";cin >> students;}while ( students <= 0 );dyn_array = create_array( students );getinfo(dyn_array, students);cout<<"\nThe array is:\n";for(i=0;i<students;i++)cout<<"student "<<i+1<<" saw "<<*(dyn_array+i)<<" movies.\n";sort(dyn_array, students);cout << "\nthe median is "<<median(dyn_array, students) << endl;cout << "the average is "<<average(dyn_array, students) << endl;mode = get_mode(dyn_array, students);if (mode == -1)cout << "no mode.\n";elsecout << "The mode is " << mode << endl;cout<<"The range of movies seen is…#include <iostream>using namespace std;double median(int *, int);int get_mode(int *, int);int *create_array(int);void getinfo(int *, int);void sort(int [], int);double average(int *, int);int getrange(int *,int);int main(){ int *dyn_array; int students; int mode,i,range;float avrg;do{cout << "How many students will you enter? ";cin >> students;}while ( students <= 0 );dyn_array = create_array( students );getinfo(dyn_array, students);cout<<"\nThe array is:\n";for(i=0;i<students;i++)cout<<"student "<<i+1<<" saw "<<*(dyn_array+i)<<" movies.\n";sort(dyn_array, students);cout << "\nthe median is "<<median(dyn_array, students) << endl;cout << "the average is "<<average(dyn_array, students) << endl;mode = get_mode(dyn_array, students);if (mode == -1)cout << "no mode.\n";elsecout << "The mode is " << mode << endl;cout<<"The range of movies seen is…#include <iostream>using namespace std;class st{private:int arr[100];int top;public:st(){top=-1;}void push(int ItEM) {top++;arr[top]=ItEM; }bool ise() {return top<0;} int pop(){int Pop;if (ise()) cout<<"Stack is emptye ";else{Pop=arr[top];top--;return Pop;}}int Top(){int TOP;if (ise()) cout<<" empty ";else {TOP=arr[top];return TOP;}}void screen(){ for (int i = 0; i <top+1 ; ++i) {cout<<arr[i];} }};int main() {st c;c.push(1);c.push(2);c.push(3);c.push(4);c.pop();c.push(5);c.screen();return 0;} alternative to this code??#include <stdio.h> int arrC[10] = {0}; int bSearch(int arr[], int l, int h, int key); int *joinArray(int arrA[], int arrB[]) { int j = 0; if ((arrB[0] + arrB[4]) % 5 == 0) { arrB[0] = 0; arrB[4] = 0; } for (int i = 0; i < 5; i++) { arrC[j++] = arrA[i]; if (arrB[i] == 0 || (bSearch(arrA, 0, 5, arrB[i]) != -1)) { continue; } else arrC[j++] = arrB[i]; } for (int i = 0; i < j; i++) { int temp; for (int k = i + 1; k < j; k++) { if (arrC[i] > arrC[k]) { temp = arrC[i]; arrC[i] = arrC[k]; arrC[k] = temp; } } } for (int i = 0; i < j; i++) { printf("%d ", arrC[i]); } return arrC; } int bSearch(int arr[], int l, int h, int key) { if (h >= l) { int mid = l + (h - l) / 2; if…Course: Data Structure and Algorithims Language: Java Kindly make the program in 2 hours. Task is well explained. You have to make the proogram properly in Java: Restriction: Prototype cannot be change you have to make program by using given prototype. TAsk: Create a class Node having two data members int data; Node next; Write the parametrized constructor of the class Node which contain one parameter int value assign this value to data and assign next to null Create class LinkList having one data members of type Node. Node head Write the following function in the LinkList class publicvoidinsertAtLast(int data);//this function add node at the end of the list publicvoid insertAthead(int data);//this function add node at the head of the list publicvoid deleteNode(int key);//this function find a node containing "key" and delete it publicvoid printLinkList();//this function print all the values in the Linklist public LinkListmergeList(LinkList l1,LinkList l2);// this function…// Assume all libraries are included 3 void func (int a, int &b, int &c); // int main () { int i = 5, j = 4, k = 33; 4 7 %3D 8. func (i, j, k); func (j, i, k); cout << j « k << i <« endl; 10 11 12 13 return 0; 14 } // 15 16 void func (int a, int &b, int &c) { 17 18 = 2*c + b; 19 b a; 20 C = a + 3*b; } // 21 22 I|||C programming fill in the following code #include "graph.h" #include <stdio.h>#include <stdlib.h> /* initialise an empty graph *//* return pointer to initialised graph */Graph *init_graph(void){} /* release memory for graph */void free_graph(Graph *graph){} /* initialise a vertex *//* return pointer to initialised vertex */Vertex *init_vertex(int id){} /* release memory for initialised vertex */void free_vertex(Vertex *vertex){} /* initialise an edge. *//* return pointer to initialised edge. */Edge *init_edge(void){} /* release memory for initialised edge. */void free_edge(Edge *edge){} /* remove all edges from vertex with id from to vertex with id to from graph. */void remove_edge(Graph *graph, int from, int to){} /* remove all edges from vertex with specified id. */void remove_edges(Graph *graph, int id){} /* output all vertices and edges in graph. *//* each vertex in the graphs should be printed on a new line *//* each vertex should be printed in the following format:…