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

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.

Article Tags :
C
Practice Tags :