Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



What is the output?

#include <stdio.h>
void main(){
  int **ptr;
  int temp = 65;
  ptr[0] = &temp;
  printf("%d", ptr[0][0]);
}





Solution

Explanation: The pointer ptr is uninitialized, so it does not point to valid memory. When the code tries to access ptr[0], it attempts to dereference an invalid location. This leads to undefined behavior, and in most cases results in a segmentation fault.


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...