main() { char *x="xyz; f(k); printf("%s\n",k); } f(char *k) { k=malloc(4); strcpy(k,"pq"); }
What will be the output?
Answer: Option [C]
There is an opening quote in the third statement but no closing. So syntax error occurs.
main() { char *x="xyz; f(k); printf("%s\n",k); } f(char *k) { k=malloc(4); strcpy(k,"pq"); }
What will be the output?
Answer: Option [C]
There is an opening quote in the third statement but no closing. So syntax error occurs.
func(int i) { if(i%2) return 0; else return 1; } main() { int i=3; i=func(i); i=func(i); printf("%d", i); }
Answer: Option [B]
int Main(int ac, char *av[]) { if(ac==0) return 0; else { printf("%s", av[ac-1]); Main(ac-1, av); } return 0; }
Answer: Option [D]
There is no error in the function. Here the Main() function differenciate with the main(). In the given problem the Main() has two arguments as int ac, char *av[]
int fn(int a, int b) { if (b==0) return 0; if (b==1) return a; return a+fn(a, b-1); }
Answer: Option [B]
The above function is a recursive function. The function will return a+b where a and b are non-negative integers
main() { int a=1, b=10; swap(a,b); printf("\n%d%d", a,b); } swap(int x, int y) { int temp; temp=x; x=y; y=temp; }
Answer: Option [B]
The 'call by value' method is applied in this program. Here the data is passed by value in the main(). So the variables are not changed.