Linux - Study Mode

[#881] What is the output of this program? #include<stdio.h>
#include<pthread.h>
#include<fcntl.h>

void *fun_t(void *arg)
void *fun_t(void *arg)
{
pthread_exit("Bye")
printf("Example
")
}
int main()
{
pthread_t pt
void *res_t
if(pthread_create(&pt,NULL,fun_t,NULL) != 0)
perror("pthread_create")
if(pthread_join(pt,&res_t) != 0)
perror("pthread_join")
printf("%s
",res_t)
return 0
}
Correct Answer

(B) Bye

[#882] In this program, the third argument of the socket() is used for . . . . . . . . potocol. #include<stdio.h>
#include<sys/types.h>
#include<sys/socket.h>
int main()
{
int fd_socket
if(socket(AF_UNIX,SOCK_STREAM,0) == -1)
perror("socket")
return 0
}
Correct Answer

(A) TCP/IP

[#883] What is the output of this program? #include<stdio.h>
#include<fcntl.h>
#include<sys/stat.h>
#include<semaphore.h>

int main()
{
sem_t* sem_id
sem_id = sem_open("sem_value",O_CREAT,0666,0)
if(sem_id == SEM_FAILED)
perror("sem_open")
sem_wait(sem_id)
printf("Example
")
if(sem_close(sem_id) == -1)
perror("sem_close")
return 0
}
Correct Answer

(B) this process will block

[#884] What is the output of this program? #include<stdio.h>

int main()
{
int *ptr
ptr = (int *)calloc(1,sizeof(int))
*ptr = 10
printf("%d
",*ptr)
return 0
}
Correct Answer

(D) none of the mentioned

[#885] Which one of the following string will print by this program? #include<stdio.h>
#include<pthread.h>
int main()
{
printf("Example
")
pthread_exit("Bye")
printf("Linux")
return 0
}
Correct Answer

(B) Example