Answer 2
======
option c) function declaration
void ActivateBuzzer(int); is a function declaration
Answer 4
=======
option D)&ptr2 = ptr1;
The option D is an invalid c++ statement. & can not come in lhs of assignment statement.
Answer 8
======
The code will print the address of the array i.e. address of first
element in the array. MyPtr is a int pointer and is assigned the
array name i.e address of first element.
Answer 10
======
option c) is an invalid statement.
option a) ptr = x; This statement assigns the address of the double array to ptr. So ptr points to this array (specifically the first element in the array). This is valid
option b) cout << *x+3; This statement is valid. It is equivalent to (*x)+3; i.e. first element in the array x plus 3 is output using cout. So the output will be 1.5+3 = 4.5
option c) *x+3 = 12; is invalid statement. This is because the LHS should always be a variable which can be assigned to. But here *x+3 evaluates to 1.5+3 = 4.5 and this can not be assigned 12; Hence this is invalid statement.
plz solve 2 ,4,8,10 " << endl; acement display? Ans: answer= B. answer 2. cu int...
C++
1.
A?B?C?D? which one is correct
2.
3A, 3B
#include<iostream> using namespace std; void swap0(int* ptri, int* ptr2) { int *temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap1(int ptri, int ptr2){ int temp; temp = ptri; ptr1 = ptr2; ptr2 = temp; portion void swap2(int *&ptri, int *&ptr2){ int* temp; temp = ptr1; ptr1 = ptr2; ptr2 = temp; void swap3(int &ptri, int &ptr2) { int temp; temp = ptr1; ptr1 = ptr2; ptr2 =...
#include <iostream> using namespace std; struct node { int base=0; int power=0; }; void insert(node ptr[],int basee,int powerr) { ptr[powerr].power=powerr; ptr[powerr].base=basee; } void subtract(node ptr1[],int size1,node ptr2[],int size2,node ptr3[]) { for(int j=0;j<=size1;j++) { if(ptr1[j].base!=0) { ptr3[j].base=(ptr3[j].base)+(ptr1[j].base); ptr3[j].power=ptr2[j].power; } } for(int j=0;j<=size2;j++) { if(ptr2[j].base!=0) { ptr3[j].base=(ptr3[j].base)-(ptr2[j].base); ptr3[j].power=ptr2[j].power; } } } void addition(node ptr1[],int size1,node ptr2[],int size2,node ptr3[]) { for(int j=0;j<=size1;j++) { if(ptr1[j].base!=0) { ptr3[j].base=(ptr3[j].base)+(ptr1[j].base); ptr3[j].power=ptr2[j].power; } } for(int j=0;j<=size2;j++) { if(ptr2[j].base!=0) { ptr3[j].base=(ptr3[j].base)+(ptr2[j].base); ptr3[j].power=ptr2[j].power; } } } void display(node ptr[],int size)...
#include <iostream> using namespace std; struct node { int base; int power; }; void insert(node ptr[],int basee,int powerr) { ptr[powerr].power=powerr; ptr[powerr].base=basee; } void addition(node ptr1[],int size1,node ptr2[],int size2,node ptr3[],int size3) { for(int j=0;j<=size1;j++) { ptr3[j].base=ptr3[j].base+ptr1[j].base; } for(int j=0;j<=size2;j++) { ptr3[j].base=ptr3[j].base+ptr2[j].base; } } void display(node ptr[],int size) { if(ptr[0].base!=0) cout<<ptr[0].base<<"+"; for(int i=1; i<=size; i++) { if(ptr[i].base!=0) cout<<ptr[i].base<<"x^"<<ptr[i].power<<"+"; } } int main() { bool choice1=true; bool choice2=true; int size1,size2,base1,base2,power1,power2; cout<<"enter the max power in polynominal 1"; cin>>size1; node *a= new node[size1+1]; for(int...
1.What will the following statement output? cout << &num1; A)None of these B)the value stored in the variable named num1 C)the number 1 D)the memory address of the variable named num1 E)the string &num1 2. What will the following code output? int number = 888; int *var = &number; cout << var << endl; A)the address of number B)an asterisk followed by 8888 C)8888 D)an asterisk followed by the address of number 3. Assuming ptr is a pointer variable, what...
C++
1. The copy constructor is used for one the following scenarios: I. Initialize one object from another of the same type. II. Copy an object to pass it as argument to a function. III. Copy an object to return it from a function. Read the following program and answer questions (20 points) #include <iostream> using namespace std; class Line public: int getLength( void); Line( int len // simple constructor Line( const Line &obj) 1/ copy constructor Line (); //...
51. What is the output of the following code snippet? int number = 0; int ptr_num -&number ptr_num 60; number-80 cout < "ptr num << endl b, 60 c. 80 d. the address of number Answer 52. What is the output of the following code snippet? double num-0.0; double* ptr = # num = 15.0; ptr ptr 15.0 cout << num <<"ptr <<endl; a. 15 15 b. 15 30 С. 30 15 d. 30 30 Answer: 53. What is the...
Question 27 The following statement ________. cin >> *num3; stores the keyboard input in the variable num3 stores the keyboard input into the pointer num3 is illegal in C++ stores the keyboard input into the variable pointed to by num3 None of these Question 28 The following statement ________. int *ptr = new int; results in a compiler error assigns an integer less than 32767 to the variable ptr assigns an address to the variable ptr creates a new pointer...
What is the output of the following? int x = 50, y = 60, z = 70; int* ptr; ptr = &x; *ptr += 10; ptr = &y; *ptr += 5; ptr = &z; *ptr -= 3; cout << x << “ ” << y << “ ” << z << endl; A) 10 5 2 B) 50 60 70 C) 60 65 67 D) 60 65 72
TRUE/FALSE 1. If pl is an integer pointer variable, with the value of 1000, pl++ changes P1 to point to the memory location 1001. ANSWER: T 2. When you return a dynamic array to the freestore, you must include the number of elements in the array 3. You can assign an array to a pointer variable. 4. The size of dynamic arrays must be declared at compile time. 5. int *pl; declares a static variable. ANSWER: F ANSWER: F ANSWER:...
1. Please answer a-d, there was a previous post with additional questions. Thank you in advance. Consider the following program and provide code and explanations where asked in the code comment after running the program in your system. Note that there are 4 parts (in bold) that need to be addressed. #include <iostream> #include <string.h> using namespace std; class Header{ private: char used; int payloadsize; char* data; public: Header (){ used = 0, payloadsize = -1, data = NULL; }...