wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

CSE325_ODD_CAP2

Total questions: 10

Worksheet time: 8mins

Name
Class
Date
1.

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?

a)

sofLPU 6

b)

sofLPU 5

c)

entsofLPU 9

d)

tsofLPU 7

2.

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

a)

11121314

b)

012131415

c)

-1

d)

1112131

3.

  What will be the output for following code?

#include <unistd.h>

int main()

{

write(1,”Covid-19”, 5);

}

a)

covid

b)

covid-

c)

Covid

d)

Covi

4.

     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);

}

a)

hell

b)

      viewe

c)

hello

d)

hello v

5.

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?

a)

Orphan process

b)

Zombie process

c)

Suspended process

d)

Ready process

6.

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?

a)

At i

b)

At 1

c)

At 2

d)

At h

7.

What is the return value of fork() in the child process?

a)

negative value

b)

zero

c)

positive value

d)

depends upon CPU

8.

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.

a)

open("os.txt", O_RDONLY | O_TRUNC, 0);

b)

open("os.txt", O_TRUNC, 0);

c)

open("os.txt", O_READ | O_TRUNC, 0);

d)

open("os.txt", O_CREAT | O_TRUNC, 0);

9.

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?

a)

open("test.txt", O_RDONLY);

b)

open("test.txt", O_CREAT|O_RDONLY, 0664);

c)

open("test.txt", O_READ);

d)

open("test.txt", O_CREATE|O_RDWR);

10.

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);

}

a)

  OK

b)

OK34567890

c)

  123OK67890

d)

1234567890