Give result #include using namespace std; class Test { static int x; public: Test() { x++; } static int getX() {return x;} }; int Test::x = 0; int main() { cout « Test::getX() « " "; Test t[5]; cout <« Test::getX(); }
Q: #include using namespace std; class SobolooSoba { int Komi(int num1,int num2) { return num1+num2;…
A: Given: A C++ program using the function overloading concept is provided. The functions are capable…
Q: #include using namespace std; class Box { Public: int length, width, sum, sub, div; Box…
A: The given program is written in the c++ programming language. It can be executed in any one of the…
Q: Student Name: 8) Consider the following ciass definitions. public class LibraryID{ private String…
A: To compare `LibraryID` objects `one` and `two` inside the if statement, you would just call the…
Q: }; private: AeroCar(double new height, double new_speed); const; { void display_data() AeroCar::…
A: C++ is an object-oriented generic programming language for creating software, and it is a…
Q: Define a function justOneMore that receives a number startNum and uses ++ to increment the number by…
A: Define a function justOneMore that receives a number startNum and uses ++ to increment the number by…
Q: #include<iostream>#include<string>class Bicycle{friend std::ostream&…
A: The objective of the question is to implement the decrement operator (--) for the Bicycle class in…
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: Condition ;;; 2. Cond (condition) function (defparameter *age* 18); Create variable age (defvar…
A: Below I have provided a program for the given question. Also, I have attached a screenshot of the…
Q: include using namespace std; aclass om { public: void set (int x,int y) cout<<"The sum =" <<x+y<<…
A: Constructor: In C++ the constructors initialize the class object. When the instance of class is…
Q: fix the getIndex function
A: Step 1: To fix the getIndex function make the following changes to function. template <typename…
Q: #include #include #include using namespace std; class Movie { private: string title =…
A: It is defined as a powerful general-purpose programming language. It can be used to develop…
Q: include void fun1(int num, ...); void fun2(int num, ...); int main() { fun1(1, "Apple", "Boys",…
A: Explanation: The code defines two functions, fun1 and fun2, which have variable arguments. In the…
Q: c++ computer language what is the output of the following code segment? int main() { int…
A: Given C++ Program: #include <iostream>using namespace std;void sub(int arr[], int z) { for(int…
Q: Describe scenarios where passing function objects as arguments can be beneficial.
A: The technique of passing function objects as arguments is widely used in software engineering to…
Q: For the “Class C”: There is 2 ways for fixing this functions. Firstly fix the “yaz” and “yaz2” error…
A: The given code is in C++ language with inheritance where 1) Class A is parent class 2) Class B…
Q: #include #include #include #include #include class CAT{ public: float weight() const{return…
A: Algorithm for CAT Class Constructor1. Start2. Define the CAT class with private member variables:…
Q: Problem For this project, you will use the Fraction class I have given you (Fraction.h and…
A: #include <iostream>#include "Fraction.h"using namespace std; int main(){ int ch;…
Q: #include using namespace std; void main() { double pi = 0, denominator = 1; int counter = 999999;…
A: Modified program code: //including necessary header file #include<iostream> using…
Q: #include using namespace std; void division (int num, int denom); int main() { division (5, -1);…
A: In this question we have been given some programs and we need to find out the correct output of the…
Q: #include #include using namespace std; class Students { protected: string firstName; string…
A: C++ is and object oriented programming language.
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: // this solves the area of a circle #include #define PI3.1415927 double Area(double r) double…
A: We need to debug the given c++ code and correct it.
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: #include using namespace std; void division(int num,int denom); int main() { division(5,-1); return…
A: Explanation:- When the denom variable is passed as less than or equal to 0 then in the division…
Q: The program should ask for the data to fill a studentRec of structure StudentRec and then ask y/n if…
A: Instruction we need to follow: The program should ask for the data to fill a studentRec of structure…
Q: In C++ QUESTION 14 class rectangleType { public: void setLengthWidth(double x, double y);…
A: In order to write and test the function definition of perimeter we also need to write the function…
Q: Condition ;;; 2. Cond (condition) function (defparameter *age* 18); Create variable age (defvar…
A: Below I have provided a program for the given question. Also, I have attached a screenshot of the…
Q: #include void main() { 19liqm00 ++ tesoronoto char charots = 'A'; gizeb mis100 for (int first = 1;…
A: Program Approach: Step 1: In this program nested loop used. Step 2: Initialize charots variable…
Q: struct ID { int x; int y; }; struct name { ID r; }; int main() { name a[2]; for (int i=0;i<2;i++) {…
A: Given code is struct ID { int x; int y; }; struct name {ID r; }; int main() { name a[2]; for(int…
Q: 26. Assume the declaration of Exercise 24. A. Write the staternents that derive the class dummyClass…
A: Dear Student, For inheritance we use the syntax - Class B extends A Here class B is the derived…
Q: Condition ;;; 2. Cond (condition) function (defparameter *age* 18); Create variable age (defvar…
A: Below I have provided a program for the given question. Also, I have attached a screenshot of the…
Q: } class ChoiceQuestion public Question { public: ChoiceQuestion(); void set_text(string new_text);…
A: In object-oriented programming (OOP), the idea of function overriding is used when a subclass offers…
Q: fix the code to able to end the program when press "q". PLease Thank you so much
A: After updating the program, I have provided C++ CODE along with OUTPUT…
Q: Add an output operator for the BigInt class. bigint.cpp 1 #include 2 #include "bigint.h" using…
A: #include <bits/stdc++.h>using namespace std; /* Function to replace every element with…
Q: #include #include using namespace std; class Staff{ public: int code; string name; public: Staff(){}…
A: Program Approach: In this code, Six class is declared "Staff, Faculty, Typist, Officer, Permanent,…
Q: Give result #include using namespace std; class Test { static int x; public: Test() { x++; } static…
A: Que. Give result Ans. Given, The programming input is in the C++ programming language. Code:…
Q: int calculatepower (int x, int y){ if (y > 0) return x* else return 1; int main (){ int num, pwr;…
A: Ans is given in next steps
Q: C++ Programing ATTRIBUTES NOTE: The important method has been given to you. userld:int //generates…
A: A class is the basic unit of object oriented design. An instance of a class is called an object. A…
Q: ype conversion, type coercion, and nonconverting type casts should all be defined.
A: Lets see the solution in the next steps
Q: #include #include #include #include #include class CAT{ public: float weight() const{return…
A: A public member function called set_range(unsigned int power) in the CAT class is intended to alter…
Q: #include #include using namespace std; class Fraction { public: int numerator; int…
A: Output of the given Program: The product of 9/8 and 2/3 is 18/24 The quotient of 9/8 and 2/3 is…
Q: Computer Science c++ help comment code please. Complex has multiple parameters to overload i think.…
A: The given class Complex has 2 private attributes real and complex The class has default constructor,…
Q: #include #include #include using namespace std; template class A { T a; U b; public:…
A: Given, The code is given in the C++ programming language Code: #include <iostream>…
Step by step
Solved in 2 steps with 2 images
- C++ complete and create magical square #include <iostream> using namespace std; class Vec {public:Vec(){ }int size(){return this->sz;} int capacity(){return this->cap;} void reserve( int n ){// TODO:// (0) check the n should be > size, otherwise// ignore this action.if ( n > sz ){// (1) create a new int array which size is n// and get its addressint *newarr = new int[n];// (2) use for loop to copy the old array to the// new array // (3) update the variable to the new address // (4) delete old arraydelete[] oldarr; } } void push_back( int v ){// TODO: if ( sz == cap ){cap *= 2; reserve(cap);} // complete others } int at( int idx ){ } private:int *arr;int sz = 0;int cap = 0; }; int main(){Vec v;v.reserve(10);v.push_back(3);v.push_back(2);cout << v.size() << endl; // 2cout << v.capacity() << endl; // 10v.push_back(3);v.push_back(2);v.push_back(3);v.push_back(4);v.push_back(3);v.push_back(7);v.push_back(3);v.push_back(8);v.push_back(2);cout…3. Smart Numbers language C++ G autocomplete.ready O 1 > #include A number is called a smart number if it's digits can be partitioned into two sets such that the sum of the digits in both sets are equal. Example: 37965 is a smart number as 3+7+5 = 9 +6 . Similarly 52139 is also a smart number as 5+2+3 = 9 10 11 * Complete the 'findCount0fSmartNumbers' function below. 12 * The function is expected to return an INTEGER. * The function accepts following parameters: 1. INTEGER A * 2. INTEGERB 13 9+1. 14 137, 328 are not smart numbers. 15 16 Your task is to find all the smart numbers in the 17 */ 18 inclusive range [A,B] . 19 int findCountofSmartNumbers(int A, int B) { 20 21 } Input 22 23 > int main()--- You will be given two integers A, B. You need to complete the function where the above integers will be given as an argument. Output Return the number of smart numbers in the inclusive range [A,B]. Constraints 1s ASBS 109 B-A s 106 Line: 9 Col:Please explain the code below #include <cstdio> #include <math.h> using namespace std; int main ( ) { // radius const int RAD = 10; // tolerance const int TOL = 5; for(int x = -RAD; x <= RAD; x++){ for(int y = -RAD; y <= RAD; y++){ int eq = x*x + y*y - RAD * RAD; printf(abs(eq) < TOL ? "*" : " "); printf(abs(eq) < TOL ? "*" : " "); } for(int y = -RAD+4; y <= RAD; y++){ int eq = x*x + y*y - RAD * RAD; printf(abs(eq) < TOL ? "*" : " "); printf(abs(eq) < TOL ? "*" : " "); } for(int y = -RAD+4; y <= RAD; y++){ int eq = x*x + y*y - RAD * RAD; printf(abs(eq) < TOL ? "*" : " "); printf(abs(eq) < TOL ? "*" : " "); } for(int y = -RAD+4; y <= RAD; y++){ int eq = x*x + y*y - RAD * RAD; printf(abs(eq) < TOL ? "*" : " ");…
- #include <algorithm> #include <iostream> #include <string> #include <vector> using namespace std; class Hotel { public: string name; int roomAvl; string location; int rating; int pricePr; }; class User : public Hotel { public: string uname; int uId; int cost; }; bool sortByIsb(Hotel& A, Hotel& B) { return A.name > B.name; } bool sortByr(Hotel& A, Hotel& B) { return A.rating > B.rating; } bool sortByRoomAvalable(Hotel& A, Hotel& B) { return A.roomAvl < B.roomAvl; } void PrintHotelData(vector<Hotel> hotels) { cout << "PRINT HOTELS DATA:" << endl; cout << "HotelName"<< " "<< "Room Avalable"<< " "<< "Location"<< " "<< "Rating"<< " "<< "PricePer Room:" << endl; for (int i = 0; i < 3; i++) { cout << hotels[i].name << " "<< hotels[i].roomAvl << " "<< hotels[i].location << " "<< hotels[i].rating << " "<<…//Test isEqual function cout << endl << "Testing isEqual function"; cout << endl << "------------------------" << endl; if (isEqual(s2, s3)) cout << "s2=\"" << s2 << "\" and s3=\"" << s3 << "\" are equal" << endl; else cout << "s2=\"" << s2 << "\" and s3=\"" << s3 << "\" are not equal" << endl; delete[] s3; s3 = getCopy(s2); if (isEqual(s2, s3)) cout << "s2=\"" << s2 << "\" and s3=\"" << s3 << "\" are equal" << endl; else cout << "s2=\"" << s2 << "\" and s3=\"" << s3 << "\" are not equal" << endl; bool isEqual(const charPtr s1, const charPtr s2){/*returns true if the cstring s1 is equal to the cstring s2Definition: Two c-strings s1 and s2 are equal if they have the same lengthand characters of s1 and s2 at corresponding indexes are the same.*/ }#include<iostream>#include<string.h>using namespace std; struct student{ int number; string name; int age; string city;}s[10]; struct module{ int number; string name; string code; int credit;}m[10]; struct assessment{ int number; int marks1; int marks2;}a[10]; int index1 =0, index2=0, index3=0; void StudentRegistration(){ if(index1==10) { cout<<"No more data can be added"<<endl; return; } string temp; cout<<"Enter personal data"<<endl; cout<<"Enter Student Number"<<endl; cin>>s[index1].number; cout<<"Enter Student Name"<<endl; getline(cin, temp); getline(cin,s[index1].name); cout<<"Enter Age"<<endl; cin>>s[index1].age; cout<<"Enter city"<<endl; getline(cin,temp); getline(cin,s[index1].city); index1++;} void ModuleEnrolment(int id){ if(index2==10) { cout<<"No more data can be…
- in c++ i have this struct struct Student { string firstName, lastName; int pointTotal; }; void printStudent(const Student & s) { cout << s.pointTotal << "\t" << s.lastName << ", " << s.firstName << endl;}void printAll(Student students[], int numStudents) { for (int i = 0; i < numStudents; i++) printStudent(students[i]); cout << endl;}int main() { const int NUMSTUDENTS = 7; Student students[NUMSTUDENTS] = { {"Brian", "Jones", 45},{"Edith", "Piaf", 45},{"Jacques", "Brel", 64},{"Anna", "Brel", 64}, {"Carmen", "Jones", 45} , {"Carmen", "Brel", 64}, {"Antoine", "Piaf", 45}, {"Pascal", "Piaf", 64} }; printAll(students, NUMSTUDENTS); sortByPointTotal(students, NUMSTUDENTS); printAll(students, NUMSTUDENTS); return 0;} i need to make a function that uses bubble sort(coded from scratch), but modify it so that the comparison for out-of-order elements takes into account all three fields:…7- ______ is the alternate of sizeof(); function. a. strtolower(); b. strtoupper(); c. isset(); d. count();C PROGRAMr Trace the values of the variables and write output of the following: #include<stdio.h>#include<conio.h>void main(){struct myStruct{int a, b;};struct myStruct myArray[5];int i;clrscr( );for(i=0;i<5;i++){myArray[i].a=i;myArray[i].b=5-i;}for(i=0;i<5;i++){printf(“%d %d %d\n”,i, myArray[i].a,myArray[i].b);}getch();}
- C++ Code /////// #include <iostream> class BTNode {public:int item;BTNode *left;BTNode *right;BTNode(int i, BTNode *l=nullptr, BTNode *r=nullptr):item(i),left(l),right(r){}}; BTNode *root = nullptr; void insert(int i) {//implement code here} int main(){insert (5);insert (10);insert (1);if (root){std::cout << "root = " << root->item << std::endl;if (root->left)std::cout << "root->left = " << root->left->item << std::endl;if (root->right)std::cout << "root->right = " << root->right->item << std::endl;}return 0;}>> IN C PROGRAMMING LANGUAGE ONLY << COPY OF DEFAULT CODE, ADD SOLUTION INTO CODE IN C #include <stdio.h>#include <stdlib.h>#include <string.h> #include "GVDie.h" int RollSpecificNumber(GVDie die, int num, int goal) {/* Type your code here. */} int main() {GVDie die = InitGVDie(); // Create a GVDie variabledie = SetSeed(15, die); // Set the GVDie variable with seed value 15int num;int goal;int rolls; scanf("%d", &num);scanf("%d", &goal);rolls = RollSpecificNumber(die, num, goal); // Should return the number of rolls to reach total.printf("It took %d rolls to get a \"%d\" %d times.\n", rolls, num, goal); return 0;}C++ complete magic Square #include <iostream> using namespace std; /*int f( int x, int y, int* p, int* q ){if ( y == 0 ){p = 0, q = 0;return 404; // status: Error 404}*p = x * y; // product*q = x / y; // quotient return 200; // status: OK 200} int main(){int p, q;int status = f(10, 2, &p, &q);if ( status == 404 ){cout << "[ERR] / by zero!" << endl;return 0;}cout << p << endl;cout << q << endl; return 0;}*/ /*struct F_Return{int p;int q;int status;}; F_Return f( int x, int y ){F_Return r;if ( y == 0 ){r.p = 0, r.q = 0;r.status = 404;return r;}r.p = x * y;r.q = x / y;r.status = 200;return r;} int main(){F_Return r = f(10, 0);if ( r.status == 404 ){cout << "[ERR] / by zero" << endl;return 0;}cout << r.p << endl;cout << r.q << endl;return 0;}*/ int sumByRow(int *m, int nrow, int ncol, int row){ int total = 0;for ( int j = 0; j < ncol; j++ ){total += m[row * ncol + j]; //m[row][j];}return total; } /*…