Skip to content
Related Articles

Related Articles

C | Pointer Basics | Question 15
  • Difficulty Level : Medium
  • Last Updated : 09 Sep, 2013




#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;
}


(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 C++ Foundation and STL concepts with the C++ Foundation and STL courses at a student-friendly price and become industry ready.

My Personal Notes arrow_drop_up
Recommended Articles
Page :