OOPS
August 29, 2024
Nielit Scientist-C 2016 march
August 29, 2024
OOPS
August 29, 2024
Nielit Scientist-C 2016 march
August 29, 2024

OOPS

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() ?

A
It output the content of the array with the characters rearranged so they are no longer recognized a the words in the original phrase.
B
It output the contents of the array with the characters shifted over by one position.
C
It outputs the contents of the array in the original order.
D
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.

Leave a Reply

Your email address will not be published. Required fields are marked *