Consider the 𝐶/𝐶++ function 𝑓() given below: void f(char w[]) { int…

UGC NET 2018

Consider the 𝐶/𝐶++ function 𝑓() 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 𝑓() ?

  1. A.

    It outputs the contents of the array in reverse order

  2. B.

    It outputs the contents of the array in the original order

  3. C.

    It outputs the contents of the array with the characters shifted over by one position

  4. D.

    It outputs the contents of the array with the characters rearranged so they are no longer recognized as the words in the original phrase

Attempted by 163 students.

Sign up free to check your answer

Sign up free

Explore the full course: Uppsc Polytechnic Lecturer 2025 Cs

Loading lesson…