You are here:

C/Confuse In Pointer...@

Advertisement


Question
Hello Sir/Madem...

  My Name Is Vandan & I Am In T.Y B.C.A.  I Need Help In Pointer In C Prog.
QUESTION  :-  HOW TO MULTIPLY TWO INTEGER VALUE USING POINTER IN C?

Answer
Hello Vandan

Here is some sample code with comments to show you how pointers can be used.

/* declare 2 integers and a result */
int a;
int b;
int result;

/* declare 2 pointers to integers
int* pa;
int* pb;

/* assign pointers */
/* pa gets address of a */
pa = &a;
/* pb gets address of b */
pb = &b;

/* assign values to the integers */
a = 2;
b = 3;

/* multiply the integers using the pointers */
/* result gets what is pointed at by pa times what is pointed at by pb */
result = *pa * *pb


When you see &a, read it as "address of a".
When you see *pa, read it as "pointed at by pa"


If anything is not clear, please ask as specific question about what you don't understand.

Best regards
Zlatko

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Expertise

No longer taking questions.

Experience

No longer taking questions.

Education/Credentials
No longer taking questions.

©2012 About.com, a part of The New York Times Company. All rights reserved.