LearnFrenzy
Sign in Take a free test

C Programming · Topic 1 of 23

Declarations and Initializations

  • 4 exercises
  • 40 questions
  • ~60 min
  • Answers explained

Interview Questions

Declarations and Initializations · Study material

Declarations and Initializations – Interview Questions

1. What is the difference between a declaration and a definition?

A declaration introduces a name and its type; a definition also allocates the object or provides the function body. extern int x; declares; int x = 3; defines.

2. Is there a difference between extern int fun(); and int fun();?

No. Function declarations have external linkage by default, so extern adds nothing.

3. What type does a real constant like 3.14 have?

double. Write 3.14f for float and 3.14L for long double.

4. What are the types of linkage in C?

External (visible across files), internal (static at file scope, one file) and none (local variables and parameters).

5. Which special character can appear in a C identifier?

Only the underscore. Identifiers use letters, digits and _, and cannot start with a digit.

6. When is a function prototype needed?

Before the first call, so the compiler knows the parameter and return types. Since C99, calling an undeclared function is an error.

7. What value does an uninitialised variable have?

Locals: indeterminate. Globals and statics: zero.

8. What happens with int a[5] = {1, 2};?

a[0] = 1, a[1] = 2, and the remaining three elements are 0.

9. What is a designated initializer?

An initializer that names its target: int a[10] = {[9] = 1}; or struct point p = {.y = 2};. Unnamed elements are zero.

10. What does volatile mean?

The object can change in ways the compiler cannot see, so every access must be performed exactly as written. Used for memory-mapped hardware and flags set by signal handlers.

11. What is a tentative definition?

A file-scope declaration without an initializer or extern, such as int count;. It may be repeated, and becomes a zero-initialised definition if no real definition follows.

12. Which declarations did C23 add?

constexpr objects, auto type inference, typeof, the empty initializer = {} and the nullptr constant.

Ready to test your Programming?

Timed online tests with instant scores and explanations.

About this section

About C Programming

C programming is the language most computer science courses start with and the foundation of operating systems, embedded devices and compilers. This section helps you learn C properly – data types, operators, control statements, functions, arrays, strings, pointers, structures, memory allocation and files – and then prove it with hundreds of practice questions explained line by line.

Why it matters

  • C teaches how a computer really works: memory, addresses and how data is stored
  • Pointers and memory questions are a favourite in written tests and technical interviews
  • Once you know C, learning C++, Java and Python becomes much easier
  • Embedded systems, operating systems and many companies' coding rounds still use C

Who it is for

  • School students (Class 11–12 computer science) building a strong programming base
  • College students (B.Tech, BCA, MCA, B.Sc CS) preparing for semester exams, lab work and viva
  • Freshers preparing for campus placements, aptitude-cum-coding tests and technical interviews
  • Anyone preparing for GATE CS or government IT exams

What every topic gives you

  • Study material in five tabs: concepts with runnable examples, coding techniques, programs, interview questions and a cheat sheet
  • MCQs that check your understanding of every concept
  • "Predict the output" puzzles – the trickiest part of written tests
  • "Find the error" programs that train you to spot bugs quickly
  • Complete programs with solutions and real output, verified on a compiler

Asked in

  • Campus placements
  • TCS, Infosys, Wipro tests
  • Technical interviews
  • GATE CS
  • University exams
  • Government IT exams

How to use this section

  1. Read the study material of a topic and run the examples yourself.
  2. Practise the four exercises – MCQs, output, errors, programs – and read every explanation.
  3. Test yourself with the timed online test, then revise the topics you got wrong.

Search LearnFrenzy

Esc

Quick links