Question 3473 – Mathematical-Reasoning
May 25, 2024NTA UGC NET Dec 2023 Paper-2
May 26, 2024Question 4908 – UGC NET CS 2018-DEC Paper-2
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() ?
Correct Answer: C
Question 41 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 .
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.
