C Language MCQ - English
Which of the following does not initialize ptr to null (assuming variable declar
Home | Discussion ForumWhich of the following does not initialize ptr to null (assuming variable declaration of a as int a=0;)?
int *ptr = &a;
int *ptr = &a – &a;
int *ptr = a – a;
All of the mentioned
Answer : A
View More Related Question
1) What will be the output of the following C code? #include <stdio.h> int *f();
int main()
{
int *p = f();
printf("%d\n", *p);
}
int *f()
{
int *j = (int*)malloc(sizeof(int));
*j = 10;
return j;
}
10
Compile time error
Segmentation fault/runtime crash since pointer to local variable is returned
Undefined behaviour
View Answer
2) Which of the following does not initialize ptr to null (assuming variable declaration of a as int a=0;)?
3) The operator used to get value at address stored in a pointer variable is
4) What will be the output of the following C code? #include <stdio.h>
void main()
{
int x = 0;
int *ptr = &5;
printf("%p\n", ptr);
}
5) What is (void*)0?