Only subtract, if they are pointers to the same type. Example:
double coefficients [12], *p= &coefficients[3], *q= &coefficients[4];
printf ("q-p=%d\n", (int)(q-p));
Note: The result is 1, not sizeof (double)
No, but subtraction between pointers to the same type is possible.
No. The only legal math you can do on two pointer variables is subtract them, but that only works if they point to elements of the same array.
You do not multiply pointers. If you want to multiply the values that they point to you must dereference them, usually with a *
Yes, two different pointer variables may point to the same memory location. Two issues, though... If your code thinks the two pointers represent two different allocations of memory, then you risk deallocating one and not realizing that the other is now invalid. You need to make sure that your compiler optimization settings for volatility are correct, otherwise the compiler could generate code that does not always work correctly.
... are usable. void pointer (generic pointer) : a special type of pointer which point to some data of no specific types. void *p; null pointer : a special type of pointer which point nowhere. it is usually used to check if a pointer is pointing to a null or free the pointer during deallocation of memory in dynamic memory allocation; it is define by using the predefine constant NULL int *p=NULL; wild pointer : uninitialized pointer. it hold a garbage value. i.e it is not pointing to any memory location yet. dangling pointer: pointer pointing to a destroyed variable. it usually happen during dynamic memory allocation when the object is destroyed but not free and the pointer is still pointing to the destroy object.
constant pointer and character pointer
The only way to swap two values using call by value semantics is to pass pointer variables by value. A pointer is a variable that stores an address. Passing a pointer by value copies the address, the value of the pointer, not the pointer itself. By passing the addresses of the two values to be swapped, you are effectively passing those values by reference. Both C and C++ use pass by value semantics by default, however C++ also has a reference data type to support native pass by reference semantics. By contrast, Java uses pass by reference semantics by default. In C, to swap two variables using pass by value: void swap (int* p, int* q) { int t = *p; *p = *q; *q = t; } In C++, to swap two variables using pass by reference: void swap (int& p, int& q) { std::swap (p, q); } Note that C++ is more efficient because std::swap uses move semantics; there is no temporary variable required to move variables. With copy semantics, a temporary is required. However, with primitive data types, there is a way to swap values without using a temporary, using a chain of exclusive-or assignments: void swap (int* p, int* q) { *p^=*q^=*p^=*q; }
You do not multiply pointers. If you want to multiply the values that they point to you must dereference them, usually with a *
When you multiply two variables with different exponents, the exponents are added. For example, if you multiply x^2 by x^3, the result is x^(2+3) = x^5. Similarly, if you multiply x^3 by x^(-2), the result is x^(3+(-2)) = x^1 = x.
If the two variables are directly proportional, then the slope can be any number,but the y-intercept has to be zero ... the line must go through the origin.
commutative
a straight line
You can print two variables with one printf, with or without pointers: int val1= 10, val2=20, *pval2= &val2; printf ("val1=%d, val2=%d\n", val1, *pval2);
Yes, two different pointer variables may point to the same memory location. Two issues, though... If your code thinks the two pointers represent two different allocations of memory, then you risk deallocating one and not realizing that the other is now invalid. You need to make sure that your compiler optimization settings for volatility are correct, otherwise the compiler could generate code that does not always work correctly.
Two numbers or variables are directly proportional if their ratio is constant. Put another way, two numbers or variables are directly proportional if one of them is a constant multiple of the other. a is proportional to b ( a ∝ b ) if a/b= constant or equivalently a=b x (constant) When to numbers or variables are directly proportional, if one doubles the other doubles, if one is halved the other is halved, etc.
... are usable. void pointer (generic pointer) : a special type of pointer which point to some data of no specific types. void *p; null pointer : a special type of pointer which point nowhere. it is usually used to check if a pointer is pointing to a null or free the pointer during deallocation of memory in dynamic memory allocation; it is define by using the predefine constant NULL int *p=NULL; wild pointer : uninitialized pointer. it hold a garbage value. i.e it is not pointing to any memory location yet. dangling pointer: pointer pointing to a destroyed variable. it usually happen during dynamic memory allocation when the object is destroyed but not free and the pointer is still pointing to the destroy object.
Two variables related in such a way that their values always have a constant ratio directly vary.
constant pointer and character pointer
A [directly] proportional relationship between two variables, X and Y implies thatY = cX where c is the constant of proportionality.