answersLogoWhite

0


Best Answer

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)

User Avatar

Wiki User

12y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

No, but subtraction between pointers to the same type is possible.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

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.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Can we directly multiply two pointer variables?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How to multiply two int pointer variable in C language?

You do not multiply pointers. If you want to multiply the values that they point to you must dereference them, usually with a *


Can two different pointer variables point to the same memory location?

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.


Different types of pointers in c language?

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


Which two pointer does not increment or decrement in arithmetic array?

constant pointer and character pointer


Swap two number using 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; }

Related questions

How to multiply two int pointer variable in C language?

You do not multiply pointers. If you want to multiply the values that they point to you must dereference them, usually with a *


What happens when you multiply two variables with different exponents?

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.


When a graph shows two variables are directly proportion the slope will be?

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.


What property of multiplication states that the order in which you multiply two variables doesnt matter?

commutative


What is the graph of two variables that are directly proportional to one another is?

a straight line


Using one pointer don't we print two variables?

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


Can two different pointer variables point to the same memory location?

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.


What is Proportional relationship of two numbers or things being measured?

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.


Different types of pointers in c language?

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


What is direct veriation?

Two variables related in such a way that their values always have a constant ratio directly vary.


Which two pointer does not increment or decrement in arithmetic array?

constant pointer and character pointer


What is a proportional relationship between 2 quantities?

A [directly] proportional relationship between two variables, X and Y implies thatY = cX where c is the constant of proportionality.