📚 Question Bank Q20 — Programming and Data Structure
Tags
Programming and Data Structure
Q20. Marks: +2.0 UGC NET Paper 2: Computer Sc 23rd August 2024 Shift 1

Consider the following code:

#include < stdio.h >

void f1(char *x, char *y) {
    char *t1; 
    t1 = x; 
    x = y; 
    y = t1;
}

void f2(char *x, char *y) {
    char *t1; 
    t1 = *x; 
    *x = *y; 
    *y = t1;
}

int main() {
    char *a = "ONE", *b = "TWO";
    
    f1(a, b); 
    printf("%s %s", a, b); // First output

    f2(&a, &b); 
    printf("%s %s", a, b); // Second output

    return 0;
}

What will be the output of the above code?

1.ONE TWO TWO ONE ✓ Correct
2.TWO ONE ONE TWO
3.ONE TWO ONE TWO
4.TWO ONE TWO ONE
📄 All “Programming and Data Structure” questions across papers
🏷 Change Tag for this Question