Consider the following C program:
The output of the program above is
c
- AHi Bye Bye Hi
- BHi Bye Hi Bye
- CBye Hi Hi Bye
- DBye Hi Bye Hi
Programming in CPointers, Multi-Dimensional Arrays, StructuresMCQ2 marks · −2/3 if wrongMedium
1#include<stdio.h>
2void fun1(char *s1, char *s2){
3 char *tmp;
4 tmp = s1;
5 s1 = s2;
6 s2 = tmp;
7}
8void fun2(char **s1, char **s2){
9 char *tmp;
10 tmp = *s1;
11 *s1 = *s2;
12 *s2 = tmp;
13}
14int main(){
15 char *str1 = "Hi", *str2 = "Bye";
16 fun1(str1, str2); printf("%s %s ", str1, str2);
17 fun2(&str1, &str2); printf("%s %s", str1, str2);
18 return 0;
19}
20A GATE question every morning
One real past-paper question every morning for your branch, answer hidden until you tap. Free on Telegram.