Question
plz solve 2 ,4,8,10
<< endl; acement display? Ans: answer= B. answer 2. cu int x = 2, y = 1; what will the following cout statement display? An
4. D. The value of variable a is changed to the value of variable b. Given the following variables/pointers, which statement
echache 2 Jennifer Islam EMPL # 29433334 Instructor Dr. La Midterm will the following code output? (10 points) MyPtr, MyNums[
10. Given double *ptr, x[5]=(1.5, 2.2, 4.3, 7.5, 9.1); which of the following statements is not valid? And explain what each
0 0
Add a comment Improve this question Transcribed image text
Answer #1

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.

Add a comment
Know the answer?
Add Answer to:
plz solve 2 ,4,8,10 " << endl; acement display? Ans: answer= B. answer 2. cu int...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • C++ 1. A?B?C?D? which one is correct 2. 3A, 3B #include<iostream> using namespace std; void swap0(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...

    #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...

    #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...

  • C++ 1. The copy constructor is used for one the following scenarios: I. Initialize one object...

    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...

    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; 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...

    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...

  • TRUE/FALSE 1. If pl is an integer pointer variable, with the value of 1000, pl++ changes...

    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:...

  • c language not c++ c language int mininum(int a[135) int i; int min. Question 2 (4...

    c language not c++ c language int mininum(int a[135) int i; int min. Question 2 (4 points) If ptr is an integer pointer and x in an integer variable then write one statement to set ptr to point to x then write another statement to increment x by 10 using ptr (not using x) (4 points) Question 3 (4 points) Saved

  • Trace the following program and display the exact outpust #incl udeci ostream» using namespace std const int siz-10 int ffx(Float ati,Float b(l, int s): bool ifp(int n) int mainO loat arysiz]-(6...

    Trace the following program and display the exact outpust #incl udeci ostream» using namespace std const int siz-10 int ffx(Float ati,Float b(l, int s): bool ifp(int n) int mainO loat arysiz]-(6,19,5,3,2,17,40,90,19,80) float ary2tsiz)-to int i,x x-ffx(aryl,ary2, ,siz): cout<<"n The values are: for(1-0:1<" ; it) ary2[i] ; cout<<" coutくくendl ; return 0; oerio int ffx(float all,float bll, int S) int i,p-0; for(i 0: i<s ; i++){ )// end for LD++]=a[i]; return p; if(ifp(ali])) bool ifp(int n)l bool ans-true for (i=2:ic, itt)...

  • Compute for Miles Per Gallon in C++

    Make a program that will calculate and compute for the quotient of miles and gallons (mpg: miles per gallons). Your program should must ask the user to specify the size of the array (using dynamic array) for the following variable: miles ,gallons and mpg. Prompt the user to Initialize  the value of miles (value for miles should be 100-250) and gallons (values should be from 5-25). Use pointer galPtr for gallons, milPtr for miles and mpgPtr for mpg.  Use function...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT