What is the output of the following code? #include using namespace std; class Shift{ public: int right(int x){ return(x << 1 ); int left(int x){ return(x >> 1); }; main(){ cout<<"\t Binary Shifting System \n"; Shift D; cout<<"After right shifting: "<
Q: What is the output of the following code? 1 #include 2 using namespace std; 3 void fun(int…
A: The above question is solved in step 2 :-
Q: void test() { int i; int a[5]; void f(int x) { a[i] = 4 i = i + 1; i = 2 * x; } i = 2; a[1] = 6;…
A: Call by copy-in-copy-out : Call by Copy-in-Copy-Out is also called as Call by Value-Result. In…
Q: Question 4 We consider the the following code: #include using namespace std; void add(int i, int…
A: Here in main() function A=1 B=2 C=3 D=1.1 We call add(A,B); => add(1,2) void add(int i,int…
Q: Q1: Complete the following program by writing its functions: static void Main(....) { } 10, 12, 7,…
A: Power(a[1], a[2], ref p); This function is wrong as a is an integer and not an array. So we cannot…
Q: In c++ Please. Given main(), complete class RandomNumbers (in files RandomNumbers.h and…
A: Het there, I am writing the required solution for the above stated question.
Q: long mult2(long, long); void multstore(long x, long y, long *dest) long t = mult2(x, y); *dest = t;…
A: To do: Convert the given code
Q: QUESTION 3 Suppose the following declarations appear in the mainfunction of a C++ program: string…
A: ANS -- 3:- Correct option -- 1. void approvedFunds(string courseP, string nameP, string & dateP,…
Q: (13.)Write a function slope(x1, y1, x2, y2) that returns the slope of the line through the points…
A: def slope(x1,y1,x2,y2): return (y2-y1)/(x2-x1)…
Q: Question 22 what is the output of the following segment of code: double m[]={2,8,1,1,8,1); int X;…
A: double m[] = {2,8,1,1,8,1};int x;for(int i=0; i<6; i++)if(m[i] ==…
Q: What is the output of the following program? #include <iostream> using namespace std;int…
A:
Q: what is the output of the following C++ code? #include using namespace std; template class Test {…
A: Given, Programming language = C++ Code: #include <iostream> using namespace std;…
Q: Question 4 We consider the the following code: #include 2 using namespace std; 3 4 void add(int i,…
A: It is defined as a direct descendant of C programming language with additional features such as type…
Q: What is the output of the following code? 1 #include 2 using namespace std; 3 void fun(int…
A: In this code, at first in the function fun, 5 is added to every element of the second row ie…
Q: Read the following program and identify the output of the progran int tmain(int argc, _TCHAR*…
A: -- operator decrements value by 1. and ++ operator increments value by 1.
Q: 63 template 64 void foo(shared_ptr ptr) 65 { 66 *ptr = T(); 67 } 68 auto p = new int(); 69 auto sp =…
A: Function call legal: Pointers can perform to call functions and to pass functions…
Q: 5) Write an overload function max that takes either two or three parameters of type double and…
A: let us see the code for the above program Function overloading is a C++ programming feature that…
Q: Q6: Write a program in C++ that contains overloaded functions with name OvOperation(). When the main…
A: C++ code for above : #include<iostream> using namespace std; //overloading functions int…
Q: a- Consider the following program written in C syntax: void swap(int a, int b) { int temp; temp = a;…
A: Actually, function is a set of statements.
Q: Consider the following function: double mystery(int x, double y, char ch){if (x > 0 &&…
A: EXPLANATION: - The static_cast function converts character to integer here EXAMPLE: -…
Q: Please write this in JAVA as well as use the Eq.txt file provided. intends to auto generate…
A: def equivalence: def __init__(self, v): self.__check(v) def __check(self, val): foo(self,…
Q: What is the output of the following program? function start(){ var arr } [2, 15, 12, 65, 17, 83];…
A: arr.remove function remove the element which is passed as parameter. In this case 2 will be removed…
Q: #include using namespace std; class fraction{ float d,s; public: fraction() { d30; s=13; }…
A:
Q: #include using namespace std%3; class fraction{ float d,s; public: fraction() { d=0; s=1%3B }…
A: Please refer below for your reference: Language used is C++ Also please check your code as in the…
Q: What is the output of the following code? int arr[] = {4, 5, 6, 7}; int *p = (arr + 1); cout << *p;…
A: Array (arr): A collection of items stored in contiguous memory spaces is referred to as an array.
Q: By using class interface write a program to show four numbers and create a friend function to find…
A: Create a class and all these attributes Now declare a function inside a class which displays values…
Q: What is the output of the following program? #include using namespace std; class abc {…
A: Question. What is the output of the following program? #include<iostream> using…
Q: 1. Explain automatic-type-conversion. 2. When can we use automatic-type-conversion? 3. When can't…
A: 1. Explain automatic-type-conversion. Type Conversion refers to conversion from one type to another.…
Q: Please write a full code in JAVA for this: A function foo has k integers as input arguments,…
A: #include #include #include #include 57 /* concatenate n copies of src into dest */ /* returns dest…
Q: Hello, I am having some trouble with this C++ homework. I have provided my code below as the…
A: Code:- #include <iostream>using namespace std;class RatNum{public:RatNum();RatNum(int numer,…
Q: 5. Consider the following program written in C syntax: void swap (int a, int b) { int temp; temp =…
A: Here we have given the explanation of the given task. You can find the solution in step 2.
Q: What will be the output of the following C+ + code? #include using namespace std; class Rect { int…
A: Question. What will be the output of the following C++ code? a) recta area: 30 rectb area: 42 b)…
Q: b) Perform white box testing on following code .Write test cases for the following code?| Printing…
A: Program Given: #include <iostream>using namespace std; int main() { for(int…
Q: What is the output of the following code? #include using namespace std; class Shift{ public: int…
A: Logic:- In the given code the 2 methods are implementing the logic of binary shifting. In one case…
Q: void test() { int i; int a[5]; void f(int x) { a[i] = 4 i=i+1; i = 2 * x; } i = 2; a[1] = 6; a[2] =…
A: Answer:
Q: the code CREATE FUNCTION Calculate_Monthly_Payment ( @mortage_amount BIGINT , @apr…
A: Our task: There is a code given in which the user has the error so ,our task is to rectify it. The…
Q: Q1) Write a function called letter grade that has a type int input parameter called points and…
A: Given: Write a function called letter grade that has a type int input parameter called points…
Q: Consider the program shown in Figure 3. Overload the prefix operator for Fraction class using a…
A: The prefix increment operator is the adds one to its operand.
Q: Read the following program and identify the output of the program. int_tmain(int argc, _TCHAR*…
A: The correct option is - a. 5,4,1 Explanation: _tmain() and _TCHAR are non-standard extensions.…
Q: i). Following is a program that implements nested functions. Write the given code into MARS and…
A: The solution for the above given question is given below:
Q: Given class Triangle (in files Triangle.h and Triangle.cpp), complete main() to read and set the…
A: Coded using C++.
Q: 1. Inspect the code and in your own interpretation, describe the reason call to function…
A: NOTE: - Since it is a multipart question, hence only the first three parts are answered below.…
Q: What is Output of the following C++ code? #include using namespace std; template void…
A: The program starts to execute from main() function. To trace the output of a program, start from…
Q: the output of the following code?
A: This program output is like this: base-1derived-2base-3base-4
Q: Why has the value of x,y,z changed even though the change occurred inside the function ? -2, y-6,…
A: Calling a function can be done in two ways and are as follows Call by value Call by reference
Q: Question 18 The correct prototype for the following function heading is void F1(Int &p1, double &p2,…
A: The correct prototype for void F1( int &p1, double &p2, bool &p3) is - void F1(int…
Q: Assume that: int x[5] = {2,4,5,7,8}; What are the values of x after calling: swap(x+2, x+4);…
A: initial x[5]={2,4,5,7,8} x[0]=2 x[1]=4 x[2]=5 x[3]=7 x[4]=8
Q: What will be the output of the following C++ program? #include using namespace std; class A{…
A: Given, Code: #include <iostream> using namespace std; class A{ public: A(){…
Q: Write a code with C to solve this problem: Given 'n' distinct numbers, how many sums of 4…
A: C code :- #include <stdio.h>int c=0;int combinationUtil(int arr[], int n, int r, int…
Step by step
Solved in 2 steps
- What is the output of the following code? // CPP program to illustrate// working of Virtual Functions#include <iostream>using namespace std; class base {public:void fun_1() { cout << "base-1\n"; }virtual void fun_2() { cout << "base-2\n"; }virtual void fun_3() { cout << "base-3\n"; }virtual void fun_4() { cout << "base-4\n"; }}; class derived : public base {public:void fun_1() { cout << "derived-1\n"; }void fun_2() { cout << "derived-2\n"; }void fun_4(int x) { cout << "derived-4\n"; }}; int main(){base* p;derived obj1;p = &obj1; // Early binding because fun1() is non-virtual// in basep->fun_1(); // Late binding (RTP)p->fun_2(); // Late binding (RTP)p->fun_3(); // Late binding (RTP)p->fun_4(); // Early binding but this function call is// illegal(produces error) because pointer// is of base type and function is of// derived class// p->fun_4(5);}Need code in C++. I have answer till part 7,please go through the code and correct it if you find any mistakes. If not answer the last 4 parts(8,9,10,11) Create a class called Line with the followings:1. Private members: p1 and p2 as pointer to Point objects (code provided below), slope and length as double variables2. Define setter and getter functions.3. Define a default constructor that allocate dynamic memory for points andset everything to 0.4. Overload a constructor that allocates memory for points, initilize themwith given arguments, and calculate the slope and length.5. Overload a destructor, a copy constructor and a copy assignment operator.6. Create a function called ”parallel” that return true when given lines areparallel and returns false otherwise7. Overload the less than (<) and greater than (>) and equality (==) oper-ators (compare the length)8. Write a functions that reads lines in the format provided in the lines.txtfrom the file and stores them in a vector named…Using C++ 11 Write a program which overloads fractions arithmetic operations for division. And include the overloading operators which we did in the class like multiplication, comparison, insertion, and extraction operators. Here is the class: class NumDays { int hr; //declaring hour variable to store hours float days; //declaring days variable to store days public: //default constructor NumDays() { hr = 0; days = 0.0; }; // parametrized constructor NumDays(int hrs) { hr = hrs; days = float(hrs / 8.0); }; // implementing getters method to return hours value from class int getHour() { return hr; } // implementing getters method to return no of days from class float getDays() { return days; } // method to implement addition operator NumDays operator + (NumDays obj) { int hrs = getHour() + obj.getHour(); NumDays temp(hrs); return temp; } // method to…
- a. Differentiate between implicit type conversiona nd Explicit type conversion with the help of example. b. What is the use of continue statement exaplin with appropriate example.19. In python we do not specify types,it is directly interpreted by the compiler, so consider the following operation to be performed.>>>x = 13 ? 2objective is to make sure x has a integer value, select all that apply (python 3.xx) a. x = 13 // 2 b. x = int(13 / 2) c. x = 13 % 2 d. All of the mentionedWhat is the output of given code? #include<iostream>using namespace std;class Base {public:Base(){ cout<<"Constructing Base \n"; }virtual~Base(){ cout<<"Destructing Base \n"; }};class Derived: public Base {public:Derived(){ cout<<"Constructing Derived \n"; }~Derived(){ cout<<"Destructing Derived \n"; }}; int main(void){Derived *d = new Derived();Base *b = d;delete b;return 0;}
- Please Solve the Question in C++ as quickly as you can in 40 minutes. And do the same as asked in the question. Don't use extra things, please. Q1: Start with the safearay class from the ARROVER3 program in Chapter 8 of Object Orient programming by Rober Lafore. Make this class into a template, so the safe array can store any kind of data. Include following member functions in Safe array class. The minimum function finds the minimum value in array. The maximum function find the maximum value in array. The average function find average of all the elements of an array. The total function finds the running total of all elements of an array. In main(), create safe arrays of at least two different types int and double and store some data in them. Then display minimum, maximum, average and total of array elements. Note: use subscript ([]) operator in sasfearay class.Need code in C++ Write a program named Averages that includes a method named Average that accepts any number of numeric parameters, displays them, and displays their average. Test your function in your Main(). Tests will be run against Average() to determine that it works correctly when passed one, two, or three numbers, or an array of numbers. Method Average can average two numbers Method Average can average three numbers Method Average can average an array of numbers using static System.Console; public class Averages { public static void Main() { // Write your main here } }Considered the following code (excution begins in main ) What is the output of the code int i = 1, /* global varible * / int j = 2 /* global varible * / void a () int i = 5; i ++; j++ ; b(); } void b() i++; prtintf "%d % d/n ", i ,j ); } void main () a (); } Assuming static (lexical scope binding off names i = j = Assuming dynamic scope binding i = j=
- . Read the following program and answer the questions given at the end. class Example { int y, z; static int x; static{x=5;} Example () { x=x+1; y=0; z=0; } Example (int a, int y, int z) { x=a; y=y; z=z; } void show(){ S.O.P(x + y+ z);}} How many data members are included in class Example, identify. What is the purpose of static block in the code. The program involves the problem of instance variable hiding. How the problem can be resolved. what will be the output of the program for the following object Example ob1=new Example (4,5,3) and Example ob2=new Example () ;Find the error(s) in the following code: class opOverload //Line 1{ //Line 2public: //Line 3opOverload operator*(); //Line 4//Overload the binary//operator *opOverload(double = 0); //Line 5private: //Line 6double decNum; //Line 7}; //Line 8PROGRAMMING LANGUAGE: C++ I need the code for clockType.h , clockTypelmp.cpp , main.cpp CLOCKTYPE.H code provided in this exercise [EVALUATE THE GIVEN CODE AND PROVIDE THE CORRECT CODE] class clockType { public: void setTime(int, int, int); void getTime(int&, int&, int&) const; void printTime() const; void incrementSeconds(); void incrementMinutes(); void incrementHours(); bool equalTime(const clockType&) const; private: int hr; int min; int sec; };