• Courses
  • Tutorials
  • Jobs
  • Practice
  • Contests

GATE | GATE CS 2018 | Question 52

Consider the following C program: C
#include <stdio.h>
void fun1(char *s1, char *s2) {
  char *temp;
  temp = s1;
  s1 = s2;
  s2 = temp;
}
void fun2(char **s1, char **s2) {
  char *temp;
  temp = *s1;
  *s1 = *s2;
  *s2 = temp;
}
int main() {
  char *str1 = \"Hi\", *str2 = \"Bye\";
  fun1(str1, str2);
  printf(\"%s %s\", str1, str2);
  fun2(&str1, &str2);
  printf(\"%s %s\", str1, str2);
  return 0;
}
The output of the program above is

(A)

Hi Bye Bye Hi

(B)

Hi Bye Hi Bye

(C)

Bye Hi Hi Bye

(D)

Bye Hi Bye Hi

Answer

Please comment below if you find anything wrong in the above post
Feeling lost in the world of random DSA topics, wasting time without progress? It's time for a change! Join our DSA course, where we'll guide you on an exciting journey to master DSA efficiently and on schedule.
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 geeks!

Last Updated :
Share your thoughts in the comments