The following statements are related to the background process in Unix. Which on
ID: 3806789 • Letter: T
Question
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. For questions 6 assume that a program contains the following declarations: char c = ''; short s = 2; int I = -3; float f = 6.5f; doubled d = 7.5; To obtain the actual size of C's integer type on a machine in a C program we can use operator and write statement Use typedef to a type named Int16 in C program. Define this types so the represents 16-bit on a 32-b machine. Use typedef to create s type named Boolean in C program to simulate the Boolean type in Java. How to represent true in C using reserved directive define? # defineExplanation / Answer
Question 5:
If a process is executing in background and tries to read from STDIN, then the processs will be suspended and it will wait for the input signal to revoke the process.
Hence, the correct choice is b) If a program executin in the background attempts to read from STDIN, it is terminated.
Question 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 printf(sizeOf(int a)).
The operator sizeOf() is used to get the size of an integer datatype and the statement to use this operator is given as follows:
int a;
printf(sizeOf(a));
Question 7:
Use typedef to create a type named Int16 in C program. Define this types so that it represents 16-bit on a 32-bit machine. typedef short int Int16
The predefined datatype is given as Int16 on a 16-bit machine. Typedef is used to change the type of a predefined datatype. The predefined datatype for integers on a 16-bit machine is short. The datatype which is needed to be change to Int16 is short int.
The statement which is used to change the predefined datatype short int to Int16 will be typedef short int Int16.
Question 8:
Use typedef to create a type named Boolean in C program to simulate the Boolean type in java. typedef enum bool{false = 0, true = 1} Boolean;
The working of Boolean type in java is given as follows:
· If the value of the boolean variable is false, then the output will be 0.
· Otherwise, the output of the boolean variable is 1.
This type of working can be achieved in C with the help of enumeration. The simulation of boolean type in java in C is shown as follows:
enum bool
{
false = 0,
true = 1
};
If the output value is false of enum type bool, then the result will be 0. Otherwise, the result will be 1. The type of enum can be changed to Boolean in C using typedef as follows:
typedef enum bool Boolean;
The name Boolean will be used in place of enum bool in the C program.
Question 9:
How to represent true in C using reserved directive define? #define true 1.
In C language, there is no true / false values but the logical values can be represented by 0 or 1 in C. For example if the result comes out to be true, then the value will be 1. Otherwise, the value will be 0.
The value true can be used in place of 1 in a C program using reserved directive define. For example: a statement written as #define A 10 will replace A in the program with the value 10.
Similarly the value true can also be replaced by 1 in the program using the syntax which is given as follows:
#define true 1
The above statement will replace the value true with 1 in the program.