Question 41
Question 42
Question 43
Question 44
# include <stdio.h>
int main ()
{
char a [6] = \"world\";
int i, j;
for (i = 0, j = 5; i < j; a [i++] = a [j--]);
printf (\"%s\\n\", a);
}
/* Add code here. Remove these lines if not writing code */
Question 45
# include <stdio.h>
# define swapl (a, b) tmp = a; a = b; b = tmp
void swap2 ( int a, int b)
{
int tmp;
tmp = a; a = b; b = tmp;
}
void swap3 (int*a, int*b)
{
int tmp;
tmp = *a; *a = *b; *b = tmp;
}
int main ()
{
int num1 = 5, num2 = 4, tmp;
if (num1 < num2) {swap1 (num1, num2);}
if (num1 < num2) {swap2 (num1 + 1, num2);}
if (num1 >= num2) {swap3 (&num1, &num2);}
printf (\"%d, %d\", num1, num2);
}
/* Add code here. Remove these lines if not writing code */
Question 46
#include <stdio.h>
int main ()
{
int i, j;
int a [8] = {1, 2, 3, 4, 5, 6, 7, 8};
for(i = 0; i < 3; i++) {
a[i] = a[i] + 1;
i++;
}
i--;
for (j = 7; j > 4; j--) {
int i = j/2;
a[i] = a[i] - 1;
}
printf (\"%d, %d\", i, a[i]);
}
/* Add code here. Remove these lines if not writing code */
Question 47
# include <stdio.h>
int main ()
{
int i, j;
char a [2] [3] = {{\'a\', \'b\', \'c\'}, {\'d\', \'e\', \'f\'}};
char b [3] [2];
char *p = *b;
for (i = 0; i < 2; i++) {
for (j = 0; j < 3; j++) {
*(p + 2*j + i) = a [i] [j];
}
}
}
/* Add code here. Remove these lines if not writing code */
Question 48
semaphore S = 1, Q = 0;
integer x;
producer: consumer:
while (true) do while (true) do
P(S); P(Q);
x = produce (); consume (x);
V(Q); V(S);
done done
Which of the following is TRUE about the program above?Question 49
An operating system implements a policy that requires a process to release all resources before making a request for another resource. Select the TRUE statement from the following:
Question 50
There are 82 questions to complete.