C Programming Interview Prep Questions
C Programming Interview Prep Questions
Basics Refresher
Datatypes
Qualifiers 1
Operators
Arithmetic Operators
What is the difference between pre and post increment? Show examples.
Logical Operators
Bitwise Operators
Ternary Operator
Usage and example.
WAP to find largest of 2 nos using ternary op
WAP to find largest of 3 nos using ternary op
Switch case
Explain switch case with an good example
Programs
Pattern program 1
5
54
543
5432
54321
Pattern program 2
*
* * *
* * * * *
* * * * * * *
* * * * * * * * *
Ref: https://www.programiz.com/c-programming/examples/pyramid-pattern
int main ()
{
int i = 1, j = 1;
for (--i && j++; i < 10; i += 2)
{
printf ("loop ");
}
return 0;
}
Typecasting
Overflow/Underflow
Pointer Basics
Note: Discuss more concepts including void pointer, NULL pointer, Dynamic memory allocation, Double
pointer, const pointer, Endianess etc in Part 2
Functions
What is the difference between pass by value and pass by reference. Show examples.
Arrays
Recursion
What is the use of extern keyword. Show usage of extern of variables and functions with simple
examples.
Q: What is a static function?
Strings
Overview of string
Why is scanf/gets not recommended to use. Why is fgets recommended. Usage of fgets
Pointers 2
WAP to allocate an integer array of size n. Store values in the array and find its sum.
Void Pointer
const pointer
More topics
Basics of 2D arrays
Preprocessing
Macros
Macros syntax
#include <stdio.h>
#define SUM(a,b) ((a) + (b))
int main()
{
int x = 5, y = 10, res;
res = SUM(x, y);
printf("%d\n", res);
res = SUM(10, 20);
printf("%d\n", res);
return 0;
}
Largest of 2 nos
#define MAX(a, b) ( a > b ? a:b)
Usage in main:
int x = 5, y = 10, large;
large = MAX(x, y);
printf("%d\n", large);
Largest of 3 nos
struct
union
Overview of union and usage
Difference between struct and union
Show usage of structure pointers
Enums
Typedef
typedef of struct
Bitfields
Other topics