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: Why does little-endian vs. big-endian matter here in this code
A: *In case of multiple questions, only the first will be answered. For other questions, put separate…
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: consider the the following code: 1 sinclude ciostream 2 using namespace std; void add(int i, int j);…
A: 14.Result: 3 15 Result: 2.1 16 Result : 6 17. Result:24 The char m is K 18.The value of variables at…
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: Question 4f. Provide the output of the following C++ code? #include using namespace…
A: Given, Programming language used = C++ Code: #include <iostream> using namespace std;…
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: 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: Q2) Write code in VB.NET using "do .. while" to solution the following : 14 25+ xy? j=6
A: VB.NET Code using DO .. While loop to print the sum of series.
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? #include using namespace std; class Shift{ public: int…
A: << is left shift operator and >> is right shift operator. Left shift is equivalent to…
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: 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: Q6: Write a program in C that contains overloaded functions with name OvOperation(). When the main…
A: Based on the argument that was passed during call of function, respective function is called if no…
Q: Which line is the declaration of function Max? 1 #include int Max (int a,int b) ; int main( ) 3 4…
A: Given: Choose the correct option.
Q: wing program void test () { int i; int [5] a; void f(int x) { a[i] = 5; i = i + 1; i = x; i = 1;…
A: Given values I=1 a[1] = 7 Function f(a[I]) Means a[1] is passed to function which is 7 Now {…
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: 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: 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: #include #include #include #include #include "team.h" const int NUM_TEAMS = 16; void…
A: Answer: I have completed your function and also I have attached code and code screenshot.
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: 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
Step by step
Solved in 2 steps with 2 images
- 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);}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…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 mentioned
- 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.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…What 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;}
- 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 } }. 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 () ;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.
- 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();}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; };