What will be the output of the following C code? #include <stdio.h> void foo(); int main() { void foo(); foo(); return 0; } void foo() { printf("2 "); }
#include <stdio.h> void main() { static int x = 3; x++; if (x <= 5) { printf("hi"); main(); } }
Run time error
hi
Infinite hi
hi hi
Which of the following is a correct format for declaration of function?
return-type function-name(argument type);
return-type function-name(argument type){}
return-type (argument type)function-name;
all of the mentioned
Which of the following function declaration is illegal?
int 1bhk(int);
int 1bhk(int a);
int 2bhk(int*, int []);
all of the mentioned
Which function definition will run correctly?
int sum(int a, int b) return (a + b);
int sum(int a, int b) {return (a + b);}
int sum(a, b) return (a + b);
none of the mentioned
Can we use a function as a parameter of another function? [Eg: void wow(int func())].
Yes, and we can use the function value conveniently
Yes, but we call the function again to get the value, not as convenient as in using variable
No, C does not support it
This case is compiler dependent
The value obtained in the function is given back to main by using ________ keyword.
return
static
new
volatile
What is the return-type of the function sqrt()?
int
float
double
depends on the data type of the parameter
Which of the following function declaration is illegal?
double func(); int main(){} double func(){}
double func(){}; int main(){}
int main() { double func(); } double func(){//statements}
None of the mentioned
What will be the output of the following C code having void return-type function?
#include <stdio.h> void foo() { return 1; } void main() { int x = 0; x = foo(); printf("%d", x); }
1
0
Runtime error
Compile time error
What will be the data type returned for the following C function?
#include <stdio.h> int func() { return (double)(char)5.0; }
char
int
double
multiple type-casting in return is illegal
What is the problem in the following C declarations?
int func(int); double func(int); int func(float);
A function with same name cannot have different signatures
A function with same name cannot have different return types
A function with same name cannot have different number of parameters
All of the mentioned
What will be the output of the following C code?
#include <stdio.h> void main() { int k = m(); printf("%d", k); } void m() { printf("hello"); }
hello 5
Error
Nothing
Junk value
What will be the output of the following C code?
#include <stdio.h> int *m() { int *p = 5; return p; } void main() { int *k = m(); printf("%d", k); }
5
Junk value
0
Error
What will be the output of the following C code?
#include <stdio.h> int *m(); void main() { int *k = m(); printf("hello "); printf("%d", k[0]); } int *m() { int a[2] = {5, 8}; return a; }
hello 5 8
hello 5
hello followed by garbage value
Compilation error
What will be the output of the following C code? #include <stdio.h> int *m(); void main() { int k = m(); printf("%d", k); } int *m() { int a[2] = {5, 8}; return a; }