C | Pointer Basics | Question 15

filter_none

edit
close

play_arrow

link
brightness_4
code

#include<stdio.h>
  
void swap (char *x, char *y)
{
    char *t = x;
    x = y;
    y = t;
}
  
int main()
{
    char *x = "geeksquiz";
    char *y = "geeksforgeeks";
    char *t;
    swap(x, y);
    printf("(%s, %s)", x, y);
    t = x;
    x = y;
    y = t;
    printf("\n(%s, %s)", x, y);
    return 0;
}

chevron_right


(A)

(geeksquiz, geeksforgeeks)
(geeksforgeeks, geeksquiz)

(B)

(geeksforgeeks, geeksquiz)
(geeksquiz, geeksforgeeks)

(C)

(geeksquiz, geeksforgeeks)
(geeksquiz, geeksforgeeks)

(D)

(geeksforgeeks, geeksquiz)
(geeksforgeeks, geeksquiz)


Answer: (A)

Explanation: See C function to Swap strings

Quiz of this Question



My Personal Notes arrow_drop_up


Article Tags :
Practice Tags :


1


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.