C Programming - Pointers - Discussion
Discussion Forum : Pointers - Point Out Correct Statements (Q.No. 2)
2.
Which of the statements is correct about the program?
#include<stdio.h>
int main()
{
int i=10;
int *j=&i;
return 0;
}
Discussion:
5 comments Page 1 of 1.
Chetan Agarwal said:
9 years ago
Actually these all are compiler dependent. In IndiaBix compiler it works whereas in more standard compilers like Turbo C it won't because you are gonna convert int*(address) to int (value).
Pranadheer said:
1 decade ago
We initialized j as *j so it becomes pointer & its declared to int type,on rhs side we have &i that means we think its a pointer type but actually its not a pointer its address of i and we have = symbol that means address is stored in pointer so "A" is wrong and "C" is correct.
Durgaprasad said:
1 decade ago
In program we created a variable i and assign value as 10.
After we initialize (declaration+assignment) a pointer which is of integer type, holding the address of i.
So the option is "C" only.
After we initialize (declaration+assignment) a pointer which is of integer type, holding the address of i.
So the option is "C" only.
$@F! said:
1 decade ago
Here j is a veriable , contain pointer.so it become pointer veriable and points to an integer type in memory location.
now address of "a" is assigning to "j" pointer, ie address of "a" store to "j" location.
hence absolutaly ans = option "C"
now address of "a" is assigning to "j" pointer, ie address of "a" store to "j" location.
hence absolutaly ans = option "C"
Kulkarni said:
1 decade ago
Please explain how is option C correct?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers