Functions in C are ALWAYS:
1.Internal
2.External
3.Both Internal and External
4.External and Internal are not valid terms for functions
The value obtained in the function is given back to main by using ________ keyword?
1.return
2.static
3.new
4.volatile
What is the output of this C code? double i; int main() { printf("%g ",i); return 0; }
1.0
2.0.000000
3.Garbage value
4.Depends on the compiler
What is the output of this C code? int x = 5; void main() { int x = 3; printf("%d", x); { int x = 4; } printf("%d", x); }
1. 3 3
2.3 4
3.3 5
4.Run time error
What is the output of this C code? void foo(); int main() { void foo(int); foo(1); return 0; } void foo(int i) { printf("2 "); }
1.2
2.Compile time error
3.Depends on the compiler
4. Depends on the standard
What is the problem in the following declarations? int func(int); double func(int); int func(float);
1.A function with same name cannot have different signatures
2.A function with same name cannot have different return types
3.A function with same name cannot have different number of parameters
4.All of the mentioned
What is the return-type of the function sqrt()
1. int
2.float
3. double
4.Depends on the data type of the parameter
Automatic variables are allocated space in the form of a:
1.stack
2.queue
3.priority
4.random
Automatic variables are stored in:
1.stack
2.data segment
3.register
4.heap
Can variable i be accessed by functions in another source file? int i; int main() { printf("%d ", i); }
1.0
2.false
3.Only if static keyword is used
4.Depends on the type of the variable
Can we use a function as a parameter of another function? [ Eg: void wow(int func()) ]
1.Yes, and we can use the function value conveniently
2.Yes, but we call the function again to get the value, not as convenient as in using variable
3.No, C does not support it
4.This case is compiler dependent
Default storage class if not any is specified for a local variable, is auto:
1.true
2.false
3.Depends on the standard
4.None of the mentioned
functions can return enumeration constants in c?
1.True
2.False
3.depends on the compiler
4.depends on the standard
functions can return structure in c?
1.True
2.False
3.Depends on the compiler
4. Depends on the standard
Property of external variable to be accessed by any source file is called by C90 standard as:
1.external linkage
2.external scope
3.global scope
4.global linkage
The output of the code below is int *m() { int *p = 5; return p; } void main() { int *k = m(); printf("%d", k); }
1.1
2.Junk value
3.0
4.5
The output of the code below is int *m(); void main() { int *k = m(); printf("hello "); printf("%d", k[0]); } int *m() { int a[2] = {5, 8}; return a; }
1.hello 5 8
2.hello 5
3. hello followed by garbage value
4.Compilation error
The output of the code below is int *m(); void main() { int k = m(); printf("%d", k); } int *m() { int a[2] = {5, 8}; return a; }
1.5
2.8
3.Nothing
4.Varies
The output of the code below is void m(int k) { printf("hi"); } void m(double k) { printf("hello"); } void main() { m(3); }
1.hi
2. hello
3.hi
4.Nothing
The output of the code below is void main() { int k = m(); printf("%d", k); } void m() { printf("hello"); }
1.hello5
2.Error
3.Nothing
4. Junk value
The scope of an automatic variable is:
1.Within the block it appears
2.Within the blocks of the block it appears
3.Until the end of program
4.Both (a) and (b)
What is the default return type if it is not specified in function definition?
1.void
2. int
3.double
4.short int
What is the output of this C code? double foo(); int main() { foo(); return 0; } foo() { printf("2 "); return 2; }
1. 2
2.Compile time error
3.Depends on the compiler
4.Depends on the standard
What is the output of this C code? int *i; int main() { if (i == 0) printf("true "); return 0; }
1.true
2.true only if NULL value is 0
3.Compile time error
4.Nothing
What is the output of this C code? int *i; int main() { if (i == NULL) printf("true "); return 0; }
1.true
2.true only if NULL value is 0
3.Compile time error
4.Nothing
What is the output of this C code? int foo(); int main() { int i = foo(); } foo() { printf("2 "); return 2; }
1.1
2.Compile time error
3.Depends on the compiler
4.Depends on the standard
What is the output of this C code? int main() { auto i = 10; const auto int *p = &i; printf("%d ", i); }
1.10
2.Compile time error
3.Depends on the standard
4.Depends on the compiler
What is the output of this C code? int x; void main() { printf("%d", x); }
1.Junk value
2.Run time error
3.0
4.Undefined
What is the output of this C code? static int x = 5; void main() { x = 9; { int x = 4; } printf("%d", x); }
1.9
2.4
3.5
4.0
What is the output of this C code? static int x; void main() { int x; printf("x is %d", x);
1.0
2.Junk value
3.Run time error
4.Nothing
What is the output of this C code? void main() { m(); m(); } void m() { static int x = 5; x++; printf("%d", x); }
1.6 7
2.6 6
3.5 5
4.5 6
What is the output of this C code? void main() { m(); printf("%d", x); } int x; void m() { x = 4; }
1.4
2.Compile time error
3.0
4.Undefined
What is the output of this C code? void main() { m(); void m() { printf("hi"); } }
1.hi
2.Compile time error
3.Nothing
4.Varies
What is the output of this C code? void main() { m(); } void m() { printf("hi"); m(); }
1.Compile time error
2.hi
3.Infinite hi
4.Nothing
What is the output of this C code? void main() { static double x; int x; printf("x is %d", x); }
1.0
2.Nothing
3.Compile time error
4.Junk value
What is the output of this C code? void main() { static int x = 3; x++; if (x <= 5) { printf("hi"); main(); } }
1. Run time error
2.hi
3. infinite hi
4.hi hi
What is the output of this C code? void main() { static int x; if (x++ < 2) main(); }
1.Infinite calls to main
2.Run time error
3.Varie
4.main is called twice
What is the output of this C code? void main() { static int x; printf("x is %d", x); }
1.0
2.1
3.Junk value
4.Run time error
What is the output of this C code? int x = 5; void main() { int x = 3; printf("%d", x); { x = 4; } printf("%d", x); }
1.Run time error
2.3
3.3 5
4.3 4
What is the output of this C code? int main() { void foo(), f(); f(); } void foo() { printf("2 "); } void f() { printf("1 "); foo(); }
1.Compile time error as foo is local to main
2.1 2
3.2 1
4.Compile time error due to declaration of functions inside main
What is the output of this C code? int main() { void foo(); void f() { foo(); } f(); } void foo() { printf("2 "); }
1.2 2
2.2
3.Compile time error
4. Depends on the compiler
What is the output of this C code? void foo(); int main() { void foo(); foo(); return 0; } void foo() { printf("2 "); }
1.Compile time error
2.2
3.Depends on the compiler
4.Depends on the standard
What is the output of this C code? void m() { printf("hi"); } void main() { m(); }
1.hi
2.Run time error
3.Nothing
4.Varies
What is the output of this C code? void m() { printf("hi"); } void main() { m(); }
1.hi
2.Run time error
3.Nothing
4.Varies
What is the output of this C code? void m(); void n() { m(); } void main() { void m() { printf("hi"); } }
1.hi
2.Compile time error
3.Nothing
4.Varies
What is the output of this code having void return-type function? void foo() { return 1; } void main() { int x = 0; x = foo(); printf("%d", x); }
1.1
2.2
3.Runtime error
4.Compile time error
What linkage does automatic variables have?
1.Internal linkage
2.External linkage
3.No linkage
4.None of the mentioned
What will be the data type returned for the following function? int func() { return (double)(char)5.0; }
1. char
2.int
3. double
4.multiple type-casting in return is illegal
What will be the output? double var = 8; int main() { int var = 5; printf("%d", var); }
1.5
2.8
3.Compile time error due to wrong format identifier for double
4.ompile time error due to redeclaration of variable with same name
What will be the output? int main() { printf("%d", d++); } int d = 10;
1.9
2.10
3.11
4.Compile time error
Which function definition will run correctly?
1.int sum(int a, int b) return (a + b);
2.int sum(int a, int b) {return (a + b);}
3.int sum(a, b) return (a + b);
4.Both (a) and (b)
Which of following is not accepted in C?
1.static a = 10; //static as
2.static int func (int); //parameter as static
3.static static int a; //a static variable prefixed with static
4.All of the mentioned
Which of the following are an external variable? int func (int a) { int b; return b; } int main() { int c; func (c); } int d;
1.a
2.b
3.c
4.d
Which of the following cannot be static in C?
1.Variables
2.Functions
3.Structures
4.None of the mentioned
Which of the following function declaration is illegal?
1.int 1bhk(int);
2.int 1bhk(int a);
3.int 2bhk(int*, int []);
4.All of the mentioned
Which of the following function declaration is illegal?
1.double func(); int main(){} double func(){}
2. double func(){}; int main(){}
3. int main() { double func(); } double func(){//statements}
4.None of the mentioned
Which of the following is a storage specifier?
1.enum
2.union
3.auto
4.volatile
Which part of the program address space is p stored in the code given below? int *p; int main() { int i = 0; p = &i; return 0; }
1.Code/text segment
2.Data segment
3.Bss segment
4.Stack