Skip to content

Beta · Data may be lost.Your data may be reset or lost.

GateBrew
← GATE CSE 2018
Questions

Q29

MCQ2 marks, −0.67ProgrammingMedium
#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:

Sign in to save attempts.

Solutions and discussion are hidden while you attempt this question. They open once you check or show the answer.