Linux - Study Mode

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

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

(D) none of the mentioned

[#947] After running this program, as your press 4, what will be the output of the program? #!/bin/bash
echo "How many times you want to print 'Example'"
read value
for ((i=0
i<$value
i++))
do
echo "Example"
done
exit 0
Correct Answer

(A) 'Example' will print 4 times

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

int main()
{
int fd
char buff[512]
if( mkfifo("/tmp/test_fifo",0666) == -1)
perror("mkfifo")
fd = open("/tmp/test_fifo",O_RDONLY)
read(fd,buff,512)
printf("%s
",buff)
return 0
}
Correct Answer

(B) this program will print nothing

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

void *fun_t(void *arg)
void *fun_t(void *arg)
{
int ret
ret = pthread_exit("Bye")
printf("%d
",ret)
}
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")
return 0
}
Correct Answer

(D) none of the mentioned

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

int main()
{
pid_t child
int a, status
a = 10
child = fork()
switch(child){
case -1 :
perror("fork")
exit(1)
case 0 :
printf("%d
",a)
break
default :
wait(&status)
break
}
return 0
}
Correct Answer

(A) 10