C Programming - Pointers - Discussion

Discussion Forum : Pointers - Find Output of Program (Q.No. 19)
19.
What will be the output of the program ?
#include<stdio.h>
power(int**);
int main()
{
    int a=5, *aa; /* Address of 'a' is 1000 */
    aa = &a;
    a = power(&aa);
    printf("%d\n", a);
    return 0;
}
power(int **ptr)
{
    int b;
    b = **ptr***ptr;
    return (b);
}
5
25
125
Garbage value
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
25 comments Page 2 of 3.

Swarnim said:   1 decade ago
In the function b is dead before returning any value. As it is creating problem of memory leak. Then how is a assigned a value 25.

VIJAY KUMAR said:   1 decade ago
a=**ptr;//a=5;
so

b=(**ptr)*(**ptr);

There are no three astricks the middle one * means multiplication.
b=5*5
b=25 .

Rohit Jindal said:   1 decade ago
How can b return a value because b is a local variable. Value will be lost after returning from function.

Kishie said:   8 years ago
b will be 25;
The program should cry with an error about the return type of the function prototype.

Jyothirmai said:   1 decade ago
In pointers how we differentiate multiplication symbol from pointer symbol.

Honey said:   1 decade ago
There are no 3 asterisks **ptr * **ptr, here middle *means multiplication.

Sidra aman said:   1 decade ago
What is the difference between **ptr and ***ptr? please explain?

Uma said:   1 decade ago
Hi i can't understand this program can anybody explain this?

Malashree said:   8 years ago
There is no return type no how it is possible to return.

Jay said:   8 years ago
Here, b is local variable, so output can be garbage!


Post your comments here:

Your comments will be displayed after verification.