1.WAP to generate segmentation fault when a program tries to access unreserved memory.

 Code:

#include <stdio.h>

void main()

{

    int num;

    printf("Enter the number : ");

    scanf("%d",num);   // [&] symbol is required to access [num] location.

    printf("%d %o %x \n",num,num,num);

}


Output:

Enter the number : 45

Segmentation fault

Comments