int *ptr; int val = 1;
ptr = val;
The second statement in the above code will assign the value 1 to
the pointer.
a) True
b) False
If you have any doubts, please give me comment...
Answer: False, If we want to assign value 1 to ptr, we need to assign the address of val(i.e. &val).
If we use this syntax, ptr has value of 1.
int *ptr;
int val = 1;
ptr = &val;
int *ptr; int val = 1; ptr = val; The second statement in the above code...
c++ questions need help QUESTION 1 Given the following code, what is the value of *ptr? int var = 5; int *ptr = &var; int *myptr = ptr; *ptr = -8; var = 0; *myptr = 2; a. 2 b. -8 c. 5 d. 0 QUESTION 2 Given the following code, what is the value of ptr+1? int arr[3] = {0, 0, 0}; int *ptr = arr; *ptr = 8; a. 9 b. undefined c. the address of arr[0] d....
Explain what each line of the following snippet of code does: int *ptr; ptr = new int; *ptr = 10; cout << ptr << ' ' << &ptr << ' ' << *ptr; delete ptr; cout << ptr << ' ' << &ptr << ' ' << *ptr;
Structure struct Node int Manth; // Mont h double dAvg: 1/ Average struct Node pNext // with, the linked İist 3hown above the function will return gven that the average is 3.8 Ptr to next -Node; Ret (3,3.8) (4,2.5) (20pts)( Recursive function) Show the code for a function that receives a pointer to the head of an ordered singly linked list that uses the structure in the top left. The function will return the pointer node that shows the highest...
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:...
#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...
#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)...
/* * Return 1 if ptr points to an element within the specified intArray, 0 otherwise. * Pointing anywhere in the array is fair game, ptr does not have to * point to the beginning of an element. Check the spec for examples if you are * confused about what this method is determining. * size is the size of intArray in number of ints. Can assume size != 0. * Operators / and % and loops are NOT allowed....
Write the pseudo code for function node* list search(node* head ptr, const node::value type& target); where head ptr is the head pointer of a linked list. The function returns a pointer to the first node containing the specified target in its data field. If there is no such node, the null pointer is returned. You can also use C++ code as you prefer.
JAVA 5) What is the output of the following code? int a = 70; boolean b = false; if(a >= 70) { System.out.print(1); if(b==true) { System.out.print(2); } } else { System.out.print(3); if(b==false) { System.out.print(4); } } System.out.print(5); 6) What is the output of the code above using these initial values? int a = 43; boolean b = false; 7) The following method is SYNTACTICALLY correct (meaning it will compile). True or false? public boolean method() { int value = 5;...
solve for the blank (make sure use C++) #include<stdio.h> int main() { int *ptr, *a; int b, c; int d[10]; b = 10 + 6; c = 10 + 1; ptr = &c; a = &b; for (b = 0; b < 10; b += 1) { d[b] = b + 2; } //*ptr = ____ //*a = ____ //b = ____ //c = ____ //d = ____ ____ ____ ____ ____ ____ ____ ____ ____ ____ b =...