Practices in quiz: 1) The following statements are related to the background pro
ID: 3591200 • Letter: P
Question
Practices in quiz:
1) The following statements are related to the background process in Unix. Which one is incorrect?
(a) To run a process in the background, we should put the special character & at the end of command
(b) If a program executing in background attempts to read from STDIN, it is terminated.
(c) If a program executes in background, the output of the program would not be displayed in screen. (d) Background process can start a new subshell.
2) Assume x is an integer type variable. To evaluate the expression x%2, what command can be used in Bourne shell?
(a) expr x%2
(b) expr x % 2
(c) expr $x%2
(d) expr $x % 2
3) Assume x is an integer type variable. What command below in Bourne shell is not equivalent to the statement x=x*2 in Java?
(a) x=`expr $x "*" 2`
(b) x='expr $x * 2'
(c) x=`expr $x '*' 2`
(d) x=`expr $x * 2`
4) Assume x is an integer type variable and assigned a value 2. Which one of the statements below is true after the execution of command x= `expr $x > 2 ` in Bourne shell?
(a) x is assigned a new value 0
(b) x is assigned a new value 1
(c) the value of x does not change
(d) a file named "2" is created in current working directory
5) Assume that a program contains the following declarations:
char c = ''; short s=2; int i=-3; float f=6.5f; double d=7.5 Give the the type of each expression listed below:
1) c*i
2) f/c
3) d/s
4) f-d
6) To obtain the actual size of C's integer type on a machine, in a C program we can use operator ____________, and write statement _____________.
7) Assume c is a char type variable, write down the output for each statement below.
(a) printf("%d", sizeof(c)); Output:_______
(a) printf("%d", sizeof(char)); Output:_______
8) Use typedef to create a type named Int16 in C program. Define the types so that they represent 16-bit on a 32-bit machine.
9) Use typedef to create a type named Boolean in C program to simulate the Boolean type in Java.
10) Use typedef to create a type named Boolean in C program to simulate the Boolean type in Java.
11) How to represent true in C using reserved word define? _________________
Explanation / Answer
1)
The incorrect statement which is related to the background process in Unix is as follows:
If a program executing in background attempts to read from STDIN, it is terminated.
Explanation:
If a background process attempts to read from STDIN, it is suspended and wait for the input.
The correct option is b)
2)
Assume x is an integer type variable. To evaluate the expression x%2, the command that can be used in Bourne shell is as follows:
expr $x%2
The correct option is c)
3)
Assume, x is an integer type variable. The command below in Bourne shell that is not equivalent to the statement x = x*2 in Java is x = ` expr $x * 2`
Explanation:
The expression x = ‘expr $x *2’ is invalid according to syntactical rules and it is not equivalent to the statement x =x*2 in Java.
The correct option is d)
4)
Assume x is an integer type variable and assigned a value 2. The statement which is true after the execution of command x = `expr $x > 2`in Bourne Shell is that x is assigned a new value 0.
Explanation:
The value x is not greater than 2, it has the value 0 which is assigned to x.
5)
The type of each expression listed below is as follows:
6)
To obtain the actual size of C’s integer type on a machine, in a C program we can use operator sizeof and write statement sizeof(int)
Explanation:
The sizeof operator is used to generate the size of a variable or datatype which is the operand. The sizeof operator can be used with any data type such as int, float or char. The syntax of the sizeof operator can be: sizeof(int), sizeof(float), sizeof(char).
7)
Assume c is a char type variable, the output of each of the statements below is as follows:
a) printf (“%d”, sizeof(c)) 1
b) printf (“%d”, sizeof(char)) 1
Explanation:
Since, c is the variable of char type so the sizeof operator will give the
8)
Since the type name is Int16 and the data type typedef is to be used which is the datatype of the pre-existing datatype, the syntax will be: typedef short int Int16.
The preexisting data-type is short int so that 16 bits can be represented on 32 bit machine.
9)
When typedef is used to create a type named Boolean in C program to simulate the Boolean type in Java the syntax will be as follows: typedef bool Boolean.
10)
When typedef is used to create a type named Boolean in C program to simulate the Boolean type in Java the syntax will be as follows: typedef bool Boolean
11)
The representation of true in C using reserved word define is as follows: #define TRUE 1
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.