Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 10

2. How to call a function without using the function name to send parameters?

a) typedefs

b) Function pointer

c) Both typedefs and Function pointer

d) None of the mentioned

View Answer

Answer: b

4. Which of the following is not possible in C?

a) Array of function pointer

b) Returning a function pointer

c) Comparison of function pointer

d) None of the mentioned

View Answer

Answer: d

6. What is the output of this C code?

#include <stdio.h>

int mul(int a, int b, int c)

return a * b * c;

void main()

int (*function_pointer)(int, int, int);

function_pointer = mul;

printf("The product of three numbers is:%d",

function_pointer(2, 3, 4));
}

a) The product of three numbers is:24

b) Run time error

c) Nothing

d) Varies

View Answer

Answer: a

. What is the output of this C code?

#include <stdio.h>

void f(int (*x)(int));

int myfoo(int);

int (*fooptr)(int);

int ((*foo(int)))(int);

int main()

fooptr = foo(0);

fooptr(10);

int ((*foo(int i)))(int)

return myfoo;

int myfoo(int i)

printf("%d\n", i + 1);

a) 10

b) 11
c) Compile time error

d) Undefined behaviour

View Answer

Answer: b

1. What does argv and argc indicate in command-line arguments?

(Assuming: int main(int argc, char *argv[]) )

a) argument count, argument variable

b) argument count, argument vector

c) argument control, argument variable

d) argument control, argument vector

View Answer

Answer: b

. Which of the following syntax is correct for command-line arguments?

a) int main(int var, char *varg[])

b) int main(char *argv[], int argc)

c) int main()

int argv, char *argc[];

d) none of the mentioned

View Answer

Answer: a

6. The first argument in command line arguments is

a) The number of command-line arguments the program was invoked with;

b) A pointer to an array of character strings that contain the arguments


c) Nothing

d) None of the mentioned

View Answer

Answer: a

4. What is the output of this C code?

#include <stdio.h>

void foo();

int main()

void foo();

foo();

return 0;

void foo()

printf("2 ");

a) Compile time error

b) 2

c) Depends on the compiler

d) Depends on the standard

View Answer

Answer: b

2. What is the output of this C code (without linking the source file in which ary1 is defined)?

#include <stdio.h>
int main()

extern ary1[];

printf("scope rules\n");

a) scope rules

b) Linking error due to undefined reference

c) Compile time error because size of array is not provided

d) Compile time error because datatype of array is not provided

View Answer

Answer: a

5. What is the scope of a function?

a) Whole source file in which it is defined

b) From the point of declaration to the end of the file in which it is defined

c) Any source file in a program

d) From the point of declaration to the end of the file being compiled

View Answer

Answer: d

1. Which of the following are themselves a collection of different data types?

a) string

b) structures

c) char

d) all of the mentioned

View Answer

Answer: b

Explanation: None.
2. User-defined data type can be derived by___________

a) struct

b) enum

c) typedef

d) all of the mentioned

View Answer

Answer: d

Explanation: None.

3. Which operator connects the structure name to its member name?

a) –

b) <-

c) .

d) Both <- and .

View Answer

Answer: c

Explanation: None.

4. Which of the following cannot be a structure member?

a) Another structure

b) Function

c) Array

d) None of the mentioned

View Answer

Answer: b

Explanation: None.

5. Which of the following structure declaration will throw an error?

a) struct temp{}s;

main(){}

b) struct temp{};
struct temp s;

main(){}

c) struct temp s;

struct temp{};

main(){}

d) None of the mentioned

View Answer

Answer: d

Explanation: None.

6. What is the output of this C code?

#include <stdio.h>

struct student

int no;

char name[20];

void main()

struct student s;

s.no = 8;

printf("hello");

a) Compile time error

b) Nothing

c) hello

d) Varies

View Answer

Answer: a
Explanation: None.

7. What is the output of this C code?

#include <stdio.h>

struct student

int no = 5;

char name[20];

};

void main()

struct student s;

s.no = 8;

printf("hello");

a) Nothing

b) Compile time error

c) hello

d) Varies

View Answer

Answer: b

Explanation: None.

8. What is the output of this C code?

#include <stdio.h>

struct student

int no;

char name[20];

};
void main()

student s;

s.no = 8;

printf("hello");

a) Nothing

b) hello

c) Compile time error

d) Varies

View Answer

Answer: c

Explanation: None.

9. What is the output of this C code?

#include <stdio.h>

void main()

struct student

int no;

char name[20];

};

struct student s;

s.no = 8;

printf("%d", s.no);

a) Nothing

b) Compile time error

c) Junk
d) 8

View Answer

Answer: d

Explanation: None.

10. Can the above code be compiled successfully?

#include <stdio.h>

struct p

int k;

char c;

float f;

};

int main()

struct p x = {.c = 97, .f = 3, .k = 1};

printf("%f\n", x.f);

a) Yes

b) No

c) Depends on the standard

d) Depends on the platform

View Answer

Answer: c

Explanation: None.

You might also like