WorksheetsCSE325_ODD_CAP2
Total questions: 10
Worksheet time: 8mins
The output of the given program is:
int main()
{
char a[20]; int b;
b=read(0,a,10);
printf("The output is %d\n",b);
}
Take input by device CSEstudentsofLPU
how many characters are left to be printed?
sofLPU 6
sofLPU 5
entsofLPU 9
tsofLPU 7
The output of given program is:
int main()
{
char a[25]; int b;
b=read(0,a,15);
write(1,a,8);
//printf("The output is %d\n",b);
}
input is 1112131415 but o/p is
11121314
012131415
-1
1112131
What will be the output for following code?
#include <unistd.h>
int main()
{
write(1,”Covid-19”, 5);
}
covid
covid-
Covid
Covi
Taking input as “hello viewers” what will be displayed on screen for following code:
int main()
{
char buff[5], buff1[20];
int n, m;
n=read(0,buff,5);
m=read(0,buff1,20);
write(1,buff,n);
}
hell
viewe
hello
hello v
A child process has completed execution but still has an entry in the process table because the parent has not called wait(). What is this called?
Orphan process
Zombie process
Suspended process
Ready process
A file f1 has content “abcdefghi1234567890”
int main()
{
int n,f,f1};
char buff[10];
f = open(“read”, O_RDWR);
read(f,buff,10);
write(1,buff,10);
read(f,buff,10);
write(1,buff,10);
}
After executing read and write for the first time what will be the cursor position?
At i
At 1
At 2
At h
What is the return value of fork() in the child process?
negative value
zero
positive value
depends upon CPU
A file named "os.txt" already exists in your system. Suppose the text "An operating system (OS) is system software that manages computer hardware, software resources, and provides services for computer programs" is written into it. Open this file for reading purpose and truncate the size to zero.
open("os.txt", O_RDONLY | O_TRUNC, 0);
open("os.txt", O_TRUNC, 0);
open("os.txt", O_READ | O_TRUNC, 0);
open("os.txt", O_CREAT | O_TRUNC, 0);
A file named "test.txt" already exists in your system. Which of the following syntax will be used to open the file for reading purpose?
open("test.txt", O_RDONLY);
open("test.txt", O_CREAT|O_RDONLY, 0664);
open("test.txt", O_READ);
open("test.txt", O_CREATE|O_RDWR);
Suppose a file “f1” has the following contents:
1234567890
What will be the contents of the file after this code is executed?
int main()
{
char b[10];
int n;
n=open(“f1”,O_RDWR);
read(n,b,3);
write(n,”OK”,2);
}
OK
OK34567890
123OK67890
1234567890
