int *p=20;
if u print like dis printf("%d",p);
o\p:- 20; how is it possible?
plz give me the explanation.
Answers were Sorted based on User's Feedback
We are assigning 20 to *p. Which means we are assigning the
address 20 to p. when you want to print the address of the
pointer variable we have to print just p not *p. if you want
to print the value stored in the particular address we need
to print like *p. in this case we are printing p so it will
give the address 20 to it.
| Is This Answer Correct ? | 31 Yes | 5 No |
Answer / valli
int *p=20;
means
int *p;
p=20;
so the address of p is 20
printf("%d",p);
it prints 20 because now the base address of p is 20
even if we print as
printf("%u",p);
the o/p will be 20
| Is This Answer Correct ? | 9 Yes | 2 No |
Answer / yogi
int *p=20;
This is like int *p;p=20;
printf("%d",p);It prints p properly as 20;
printf("%d",*p);It means deference the value at address 20,
which is invalid .
If we try to run,as address 20 is invalid and it tries to
fetch the value at address 20,signal 11 sent to that process
i.e it dumps core with segmentation fault
| Is This Answer Correct ? | 4 Yes | 0 No |
Answer / thunder
GIVES THE ERROR DURING COMPILATION.
*P means IT CAN STORE ADDRESS NOT ANY INTEGER VALUE.
| Is This Answer Correct ? | 6 Yes | 5 No |
Answer / saikishore
correct ans is
int *p ; // creating a pointer of integer type
*p=20; // we are creating memory for 20 and p is pointing to
it .
printf("%d",p); // prints p 's address
printf("%d",*p); // prints value pointed by p . i.e 20
wrong declarations
we
ERRORS 1.int *p=20;
| Is This Answer Correct ? | 4 Yes | 3 No |
Answer / udanesh
int *p=20 means
int *p;
p=20;
so when you print the value of p definitely you will get the output as 20 because the value of p is 20
| Is This Answer Correct ? | 1 Yes | 0 No |
Answer / sangram
p is a pointer and it holds address.
we are assigning 20 to p;it means pointer p points the value pointed by address 20.
so to show the value on address 20 you have give *p
| Is This Answer Correct ? | 0 Yes | 0 No |
Answer / deepak
/*int *p=20;
is same as*/
int *p;
p=20;
so p having address of an integer value;
so
printf("%d,%u",p,p);
will give you answer 20,20
| Is This Answer Correct ? | 0 Yes | 1 No |
Answer / sateeshbabu aluri
we are not printing the address of variable
it mens &p;
we are printing value of p.
so,P=20 will be the o/p.
| Is This Answer Correct ? | 3 Yes | 5 No |
Answer / ankit
it will show compiler error as we are trying to assign integer value to pointer variable.
| Is This Answer Correct ? | 1 Yes | 3 No |
What is difference between && and & in c?
array contains zeros and ones as elements.we need to bring zeros one side and one other side in single parse. ex:a[]={0,0,1,0,1,1,0,0} o/p={0,0,0,0,0,1,1,1}
Consider the following C program. #include <stdio.h> int main() { int i; for (i=0;i<3;++i) { fork();fork(); } } How many processes are created when running this program (including the initial one)? Explain
What is the output for the program given below typedef enum grade{GOOD,BAD,WORST,}BAD; main() { BAD g1; g1=1; printf("%d",g1); }
Do you know what is the purpose of 'extern' keyword in a function declaration?
how to find a 5th bit is set in c program
How do i store a paragraph into a string? for example, if i input a long paragraph, the program will read the words one by one and concatenate them until no word is left.
How can a process change an environment variable in its caller?
Which is not valid in C? 1) class aClass{public:int x;} 2) /* A comment */ 3) char x=12;
Consider a language that does not have arrays but does have stacks as a data type.and PUSH POP..are all defined .Show how a one dimensional array can be implemented by using two stacks.
How would you use the functions fseek(), freed(), fwrite() and ftell()?
0 Answers Aspire, Infogain, TISL,
How can I call a function, given its name as a string?