Top

Declarations and Initializations

11.

Is it true that a global variable may have several declarations, but only one definition?

Answer: A

Yes, In all the global variable declarations, you need to use the keyword extern.

Enter details here

12.

The name of the variable used in one function cannot be used in another function?

Answer: B

No answer description available for this question.

Enter details here

13.

By default a real number is treated as a

Answer: B

No answer description available for this question.

Enter details here

Answer: C

No answer description available for this question.

Enter details here

15.

When we mention the prototype of a function?

Answer: B

No answer description available for this question.

Enter details here

16.

Is there any difference in the following declarations?
int myfun(int arr[]);
int myfun(arr[20]);

Answer: A

Yes, we have to specify the data type of the parameter when declaring a function.

Enter details here

17.

Which of the following declaration is not supported by C?

Answer: A

No answer description available for this question.

Enter details here

18.

Which keyword is used to prevent any changes in the variable within a C program?

Answer: C

const is a keyword constant in C program.

Enter details here

19.

A variable declared in a function can be used in main?

Answer: B

No answer description available for this question.

Enter details here

20.

Does this compile without error?

int main()
{
for (int k = 0; k < 10> return 0;
}

Answer: C

Compilers implementing C90 does not allow this but compilers implementing C99 allow it.
Output:
$ cc pgm4.c
pgm4.c: In function ‘main’:
pgm4.c:4: error: ‘for’ loop initial declarations are only allowed in C99 mode
pgm4.c:4: note: use option -std=c99 or -std=gnu99 to compile your code

Enter details here

Loading…
Tags: Declarations and Initializations Questions and Answers || Declarations and Initializations MCQ Questions and Answers || Declarations and Initializations GK Questions and Answers || Declarations and Initializations GK MCQ Questions || Declarations and Initializations Multiple Choice Questions and Answers || Declarations and Initializations GK || GK on Declarations and Initializations || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming