Skip to content
  1. Home
  2. Guides
  3. C questions for freshers

Basic C Interview Questions for Freshers (2026) — 30 Questions with Answers

By Abhishek Kumar Updated 20 November 2026 6 min read

Key takeaways

  • These 30 questions cover the basic C topics asked in campus placements and first-round interviews at TCS, Infosys, Wipro, Accenture and product startups.
  • Interviewers check pointers, arrays vs pointers, strings, storage classes and memory most — revise those first.
  • Practise the 10 programs at the end by hand. Machine-test rounds repeat them every year.

C is still the first language tested in most campus placements, because it shows whether you understand what the machine actually does — memory, pointers and data representation. Below are the 30 basic C interview questions for freshers that come up again and again, with short answers you can say in an interview. For deeper explanations and 100+ questions, see the complete C programming interview questions guide.

C language basics

1. What is C, and why is it called a middle-level language?

C is a general-purpose, procedural programming language created by Dennis Ritchie at Bell Labs in 1972. It is called middle-level because it combines high-level features (functions, structured control flow) with low-level access to memory through pointers and bitwise operations.

2. What are the main features of C?

C is portable, fast, procedural, has a small set of keywords, a rich library, pointers and direct memory access, recursion, and dynamic memory allocation. It is used for operating systems, compilers, embedded systems and databases.

3. What are the basic data types in C?

int, char, float, double and void, combined with the modifiers short, long, signed and unsigned. Sizes depend on the platform — on most 64-bit systems, int is 4 bytes and double is 8. Use sizeof rather than assuming.

C
printf("%zu %zu %zu\n", sizeof(int), sizeof(long), sizeof(double));

4. What is the difference between = and ==?

= is the assignment operator; == is the equality comparison operator. if (x = 5) assigns 5 and is always true — a classic bug. Compilers warn about it with -Wall.

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

A declaration tells the compiler a name and its type (extern int count;). A definition also allocates storage or provides the body (int count = 0;). A variable can be declared many times but defined only once.

6. What are format specifiers?

Placeholders in printf/scanf that tell the function the type of each argument: %d int, %u unsigned, %ld long, %f float/double in printf, %lf double in scanf, %c char, %s string, %p pointer, %x hex, %zu size_t.

7. What is the difference between while and do-while?

while checks the condition before each iteration, so the body may run zero times. do-while checks after, so the body runs at least once.

8. What is the difference between break and continue?

break exits the nearest loop or switch immediately. continue skips the rest of the current iteration and moves to the next one.

Pointers, arrays and strings

9. What is a pointer?

A pointer is a variable that stores a memory address. & gives the address of a variable and * dereferences a pointer to access the value at that address.

C
int x = 10;
int *p = &x;
*p = 20;           // x is now 20
printf("%d %p\n", x, (void *)p);

10. What is a NULL pointer?

A pointer that points to nothing, written NULL. Initialise pointers to NULL and check before dereferencing — dereferencing NULL is undefined behaviour and usually crashes the program.

11. What is a dangling pointer?

A pointer that still holds the address of memory that has been freed or has gone out of scope. Using it is undefined behaviour. Set pointers to NULL after free() and never return the address of a local variable.

12. What is a void pointer?

A generic pointer (void *) that can hold the address of any data type. It must be cast to a specific type before dereferencing. malloc returns void *.

13. What is the difference between an array and a pointer?

An array is a fixed block of contiguous elements; its name decays to a pointer to the first element in most expressions. But sizeof(arr) gives the whole array's size while sizeof(ptr) gives the pointer's size, and an array name cannot be reassigned.

14. What is call by value vs call by reference?

C always passes arguments by value (a copy). To let a function modify the caller's variable, pass its address (a pointer) — this simulates call by reference.

C
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }
int x = 1, y = 2;
swap(&x, &y);      // x = 2, y = 1

15. How are strings stored in C?

As arrays of char terminated by the null character '\0'. "hi" occupies 3 bytes. Functions such as strlen, strcpy and strcmp rely on that terminator.

16. What is the difference between strlen() and sizeof() for strings?

strlen(s) counts characters up to (but not including) '\0' at runtime. sizeof(arr) gives the total bytes the array occupies at compile time. For char s[10] = "hi";, strlen is 2 and sizeof is 10.

Functions, storage classes and memory

17. What are storage classes in C?

auto (the default for locals), register (a hint to keep the variable in a CPU register), static (keeps its value between calls, or limits visibility to the file) and extern (declares a variable defined in another file).

18. What does static mean for a local variable and for a global?

A static local variable is initialised once and keeps its value between function calls. A static global variable or function is visible only within its own source file (internal linkage).

C
int counter(void) { static int n = 0; return ++n; }  // 1, 2, 3 ...

19. What is recursion?

A function calling itself, with a base case that stops it. It suits problems such as factorial, Fibonacci and tree traversal. Each call uses stack space, so deep recursion can overflow the stack.

20. What is the difference between malloc() and calloc()?

malloc(n) allocates n bytes of uninitialised memory. calloc(count, size) allocates count × size bytes and zero-initialises them. Both return NULL on failure and must be released with free().

21. What is a memory leak?

Memory allocated with malloc/calloc that is never freed, so the program's memory use keeps growing. Fix it by freeing every allocation exactly once, including on error paths, and detect leaks with Valgrind or AddressSanitizer.

22. What is the difference between a structure and a union?

A structure allocates separate memory for each member, so all members can hold values at once. A union shares one memory block among all members (its size is that of the largest member), so only one member is valid at a time.

23. What is typedef?

typedef creates an alias for an existing type to improve readability: typedef struct { int x, y; } Point; lets you write Point p;.

24. What is the difference between #include <file> and #include "file"?

<file> searches the system include directories (standard headers). "file" searches the current directory first, then the system paths (your own headers).

25. What are macros, and how do they differ from functions?

Macros (#define) are text substitutions done by the preprocessor before compilation — no type checking and no function-call overhead, but they can cause bugs with side effects. Always parenthesise macro arguments.

C
#define SQUARE(x) ((x) * (x))

Top C programs to practise for freshers

26. Reverse a string in place

C
void reverse(char *s) {
    for (int i = 0, j = (int)strlen(s) - 1; i < j; i++, j--) {
        char t = s[i]; s[i] = s[j]; s[j] = t;
    }
}

27. Check whether a number is a palindrome

C
int is_palindrome(int n) {
    int rev = 0, orig = n;
    while (n > 0) { rev = rev * 10 + n % 10; n /= 10; }
    return orig == rev;
}

28. Check whether a number is prime

C
int is_prime(int n) {
    if (n < 2) return 0;
    for (int i = 2; i * i <= n; i++)
        if (n % i == 0) return 0;
    return 1;
}

29. Print the Fibonacci series

C
void fib(int n) {
    long a = 0, b = 1;
    for (int i = 0; i < n; i++) { printf("%ld ", a); long t = a + b; a = b; b = t; }
}

30. Swap two numbers without a temporary variable

C
a = a + b;  b = a - b;  a = a - b;    // beware of overflow
// or with XOR (a and b must not be the same variable):
a ^= b; b ^= a; a ^= b;

Other programs worth writing once by hand: factorial (iterative and recursive), Armstrong number, counting vowels, bubble sort, binary search, matrix multiplication and a singly linked list with insert and delete.

How to use this list

Read each question, answer it out loud in under 30 seconds, then check the answer. Mark the ones you stumble on and revise them with the detailed explanations in the full C interview guide. Then test yourself with the free C quiz and move on to data structures interview questions, which usually come next in placement rounds.

Frequently asked questions

What C questions are asked for freshers in campus interviews?
The most common are: features of C, data types and format specifiers, the difference between = and ==, pointers and arrays, call by value vs call by reference, static and extern, structures vs unions, malloc vs calloc, and simple programs such as palindrome, factorial, Fibonacci, prime check, swap and string reverse.
How many days does it take to prepare C for a fresher interview?
With basic knowledge, 7–10 focused days are enough: 2 days on syntax and data types, 3 days on pointers, arrays and strings, 2 days on structures, memory and storage classes, and the rest writing the common programs by hand.
Is C enough to get a job as a fresher?
C alone rarely gets you a job, but strong C fundamentals help you clear aptitude and technical rounds and make learning C++, Java, embedded systems and data structures much easier. Pair it with DSA and one modern language.
AK
Abhishek Kumar
Founder, InterviewPitch · 10+ years in IT. Writes InterviewPitch's guides from real interview experience.