answersLogoWhite

0


Want this question answered?

Be notified when an answer is posted

Add your answer:

Earn +20 pts
Q: Who hit the first 3 pointer in the ACC?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the first person to shoot a 3 pointer?

d.j. erving


What are the application of this pointer can you use this pointer in friend function justify?

The this pointer can only be used within nonstatic member functions. Friend functions are not members so they have no access to a this pointer. However, you can pass a specific instance of a class to a function via a class reference argument. To understand how friendship works, first understand that a nonstatic member function has the following properties: 1. It has private access to the class. 2. It is scoped to the class. 3. It must be invoked upon an object of the class (has a this pointer). Static member functions have the first two properties while friend functions only have the first property.


Write a c program to insert an element in the beginning at the end at the specified position in a linear linked list?

#include<stdio.h> #include<stdlib.h> typedef struct Node { int data; struct Node *next; }node; void insert(node *pointer, int data) { /* Iterate through the list till we encounter the last node.*/ while(pointer->next!=NULL) { pointer = pointer -> next; } /* Allocate memory for the new node and put data in it.*/ pointer->next = (node *)malloc(sizeof(node)); pointer = pointer->next; pointer->data = data; pointer->next = NULL; } int find(node *pointer, int key) { pointer = pointer -> next; //First node is dummy node. /* Iterate through the entire linked list and search for the key. */ while(pointer!=NULL) { if(pointer->data == key) //key is found. { return 1; } pointer = pointer -> next;//Search in the next node. } /*Key is not found */ return 0; } void delete(node *pointer, int data) { /* Go to the node for which the node next to it has to be deleted */ while(pointer->next!=NULL && (pointer->next)->data != data) { pointer = pointer -> next; } if(pointer->next==NULL) { printf("Element %d is not present in the list\n",data); return; } /* Now pointer points to a node and the node next to it has to be removed */ node *temp; temp = pointer -> next; /*temp points to the node which has to be removed*/ pointer->next = temp->next; /*We removed the node which is next to the pointer (which is also temp) */ free(temp); /* Beacuse we deleted the node, we no longer require the memory used for it . free() will deallocate the memory. */ return; } void print(node *pointer) { if(pointer==NULL) { return; } printf("%d ",pointer->data); print(pointer->next); } int main() { /* start always points to the first node of the linked list. temp is used to point to the last node of the linked list.*/ node *start,*temp; start = (node *)malloc(sizeof(node)); temp = start; temp -> next = NULL; /* Here in this code, we take the first node as a dummy node. The first node does not contain data, but it used because to avoid handling special cases in insert and delete functions. */ printf("1. Insert\n"); printf("2. Delete\n"); printf("3. Print\n"); printf("4. Find\n"); while(1) { int query; scanf("%d",&query); if(query==1) { int data; scanf("%d",&data); insert(start,data); } else if(query==2) { int data; scanf("%d",&data); delete(start,data); } else if(query==3) { printf("The list is "); print(start->next); printf("\n"); } else if(query==4) { int data; scanf("%d",&data); int status = find(start,data); if(status) { printf("Element Found\n"); } else { printf("Element Not Found\n"); } } } }


Explain pointer of any data type that requires four bytes?

When a pointer to a data type that requires four bytes is declared, the compiler knows that the target object is four bytes in size. When the program then performs a calculation to offset the pointer, such as to add 3 (for instance) to the pointer, the generated code actually adds 12. This is because the compiler assumes that adding or subtracting numbers to or from a pointer is an attempt to use the pointer in an array context. (Actually, this behavior is defined in the language specification.)The other valid arithmetic manipulation of a pointer is subtraction of two pointers to the same type of object. In this case, again, an internal multiplier of 4 is applied, and the result is an offset that could be used if the first pointer were the base of an array of those objects.The size of the target object could be any value, such as a double which might be 8 bytes. The compiler will do the arithmetic correctly.Also, keep in mind the distinction between the size of the pointer and the size of the object to which the pointer points. This answer assumes the latter.In any case, the programmer must insure that the calculation results in a pointer or offset value that represents an address in the base object array, assuming that the allocated space of that object is correct. Any other result is inconsistent with the defined usage of a pointer, and the result of dereferencing such an inconsistent pointer or offset is undefined by the language specification, and could result in corruption, incorrect behavior, or crash.


How many bytes are required to store the pointer?

It depends on the platform... In a 16 bit environment, such as DOS or Windows 3.x, a near pointer is two bytes, while a far pointer is 4 bytes. In a 32 bit environment, such as Win32, a pointer is 4 bytes. In a 64 bit environment, such as Win64, a pointer is 8 bytes. If you want to find out in your particular environment, look at sizeof(ptr), where ptr is declared as a pointer to something. char* ptr; std::cout << sizeof(ptr) << std::endl; Note that the size of the pointer is not the same as the size of the object to which it points. If you looked at sizeof(*ptr), you would get 1.