Teaching UGC NET Mock Test Series 2025 (Paper 1 & 2) Programming and Data Structure Programming in C Function Recursion
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
2
TWO ONE ONE TWO
3
ONE TWO ONE TWO
4
TWO ONE TWO ONE