Linux Startup and Shutdown Question:
Download Questions PDF

What is the output of this program?

#include<stdio.h>

int main()
{
int *ptr;
ptr = (int *)calloc(1,sizeof(int));
*ptr = 10;
printf("%dn",*ptr);
return 0;
}
a) 0
b) -1
c) 10
d) none of the mentioned

Linux Shutdown & Startup Interview Question
Linux Shutdown & Startup Interview Question

Answer:

d) none of the mentioned
Explanation:
This program will give an error because calloc() requires the header file stdlib.h.
Output:
[root@localhost google]# gcc -o san san.c
san.c: In function 'main':
san.c:6:15: warning: incompatible implicit declaration of built-in function 'calloc' [enabled by default]
[root@localhost google]#

Download Linux Shutdown & Startup Interview Questions And Answers PDF

Previous QuestionNext Question
Do you have any idea what is the output of this program?

#include<stdio.h>
#include<stdlib.h>

int main()
{
int *ptr;
*ptr = 10;
*ptr = 20;
printf("%dn",*ptr);
return 0;
}
a) 10
b) 20
c) segmentation fault
d) none of the mentioned
On Linux, initrd is a file:
a) containing root file-system required during bootup
b) Contains only scripts to be executed during bootup
c) Contains root-file system and drivers required to be preloaded during bootup
d) None of the above