C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 2)
2.
What will be the output of the program ?
#include<stdio.h>
int main()
{
int i=3, *j, k;
j = &i;
printf("%d\n", i**j*i+*j);
return 0;
}
Discussion:
65 comments Page 7 of 7.
Rakesh said:
1 decade ago
Munny and nihar gave correct explanation.
Sona said:
1 decade ago
i**j*i+*j
above line executed in following steps
i*(*j)*i+(*j)
now since i=*j=3
therefore
i**j*i+*j=i*(*j)*i+(*j)=3*(3)*3+(3)=30
above line executed in following steps
i*(*j)*i+(*j)
now since i=*j=3
therefore
i**j*i+*j=i*(*j)*i+(*j)=3*(3)*3+(3)=30
Nihar said:
1 decade ago
i**j*i+*j
Here the * symol before j is pointer value of j and * symbol before i and after i is for multiplication.
So the execution will be
i**J = 3*3 = 9
i**j*i = 9*3 = 27
i**j*i+*j = 27+3 = 30.
Here the * symol before j is pointer value of j and * symbol before i and after i is for multiplication.
So the execution will be
i**J = 3*3 = 9
i**j*i = 9*3 = 27
i**j*i+*j = 27+3 = 30.
Munny said:
2 decades ago
j=&i implies *j=i;
*j=3
i**j=3*3=9
i**j*i=9*3=27
i**j*i+*j=27+3=30
*j=3
i**j=3*3=9
i**j*i=9*3=27
i**j*i+*j=27+3=30
Shunmu said:
2 decades ago
i**j*i+*j
above line executed in following steps
1>i**j
3**3=9
2>i**j*i
9*3=27(9 from the previous step)
3>i**j*i+*j
27+*j=27+*j=27+3=30
above line executed in following steps
1>i**j
3**3=9
2>i**j*i
9*3=27(9 from the previous step)
3>i**j*i+*j
27+*j=27+*j=27+3=30
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers