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 |
The operation of a stair case switch best explains the a) or operation b) and operation c)exclusive nor operation d)exclusive or operation Which of the following is/are syntactically correct? a) for(); b) for(;); c) for(,); d) for(;;);
1 Answers HCL, Public Service Commission,
A banker has a seif with a cipher. Not to forget the cipher, he wants to write it coded as following: each digit to be replaced with the difference of 9 with the current digit. The banker chose a cipher. Decipher it knowing the cipher starts with a digit different than 9. I need to write a program that takes the cipher from the keyboard and prints the new cipher. I thought of the following: Take the input from the keyboard and put it into a string or an array. Go through the object with a for and for each digit other than the first, substract it from 9 and add it to another variable. Print the new variable. Theoretically I thought of it but I don't know much C. Could you give me any kind of hint, whether I am on the right track or not?
How to set a variable in the environment list?
what is the role you expect in software industry?
what is diognisis?
There is a number and when the last digit is moved to its first position the resultant number will be 50% higher than the original number.Find the number?
size maximum allocated by calloc()
Why do we use & in c?
How can I do serial ("comm") port I/O?
What are the __date__ and __time__ preprocessor commands?
get any number as input except 1 and the output will be 1.without using operators,expressions,array,structure.don't print 1 in printf statement
4.A function 'q' that accepts a pointer to a character as argument and returns a pointer to an array of integer can be declared as: A)int (*q(char*)) [] B)int *q(char*) [] C)int(*q)(char*) [] D)None of the Above