Top

Discussion

What is the output of following program?

#include 
void swap(char *str1, char *str2) 
{ 
  char *temp = str1; 
  str1 = str2; 
  str2 = temp; 
}   
    
int main() 
{ 
  char *str1 = "Geeks"; 
  char *str2 = "Quiz"; 
  swap(str1, str2); 
  printf("str1 is %s, str2 is %s", str1, str2); 
  return 0; 
} 

 

  • A.str1 is Quiz, str2 is Geeks
  • B.str1 is Geeks, str2 is Quiz
  • C.str1 is Geeks, str2 is Geeks
  • D.str1 is Quiz, str2 is Quiz

Answer: B

No answer description available for this question.
 

No comment is present. Be the first to comment.
Loading…

Post your comment