OOPS
August 29, 2024Nielit Scientist-C 2016 march
August 29, 2024OOPS
|
Question 81
|
Consider the C/C++ function f() given below:
void f(char w []) { int x = strlen(w); //length of a string char c; For (int i = 0; i < x; i++) { c = w[i]; w[i] = w[x - i - 1]; w[x - i - 1] = c; } }
Which of the following is the purpose of f() ?
|
It output the content of the array with the characters rearranged so they are no longer recognized a the words in the original phrase.
|
|
|
It output the contents of the array with the characters shifted over by one position.
|
|
|
It outputs the contents of the array in the original order.
|
|
|
It outputs the contents of the array in the reverse order.
|
Question 81 Explanation:
It outputs the contents of the array in the original order because it swaps pairs of elements at locations (i and x – i – 1) twice.
Correct Answer: C
Question 81 Explanation:
It outputs the contents of the array in the original order because it swaps pairs of elements at locations (i and x – i – 1) twice.
