Placement Prep

Introduction to C Programming: Basics and Fundamentals

C programming fundamentals for engineering students: Hello World breakdown, variables, data types, the compilation pipeline, and two worked programs.

By FACE Prep Team 5 min read
c-programming programming-basics placement-prep beginner compilation variables

C is a compiled, statically typed, procedural language developed by Dennis Ritchie at Bell Labs between 1969 and 1973, and it still runs inside every major operating system, embedded controller, and database engine in production today.

That longevity is relevant for placement preparation. Most data structures interview questions (arrays, linked lists, trees, stacks) are easiest to reason about in C because C exposes exactly how data sits in memory. Understanding C first means those concepts stop being abstract.

Why C Still Matters in 2026

Two domains keep C dominant: embedded systems and operating systems.

Every microcontroller in an automotive ECU, industrial sensor, or consumer appliance runs firmware written primarily in C. The language has no garbage collector, no runtime overhead beyond the program itself, and maps almost directly to the hardware instruction set. Those properties are non-negotiable when the target chip has 64 KB of RAM.

At the OS level, the Linux kernel is written in C. So are large portions of Windows and macOS. The C language reference on cppreference.com documents the standard that all these implementations conform to.

For placements specifically: semiconductor companies (Qualcomm, Texas Instruments, Renesas), embedded software firms, and product companies that write close-to-metal code routinely ask C questions in technical rounds. Even at service-tier companies, C programs (swap without a third variable, palindrome check, prime sieve) appear in online tests because they test pointer reasoning cheaply.

Your First C Program: Breaking Down Hello World

#include <stdio.h>

int main(void) {
    printf("Hello, World!\n");
    return 0;
}

Every line above has a job.

#include <stdio.h> is a preprocessor directive. Before the compiler sees your code, the C preprocessor runs first. It finds the <stdio.h> header file (Standard Input/Output) and pastes its function declarations (including printf()) into your source. Without this line, the compiler would encounter printf as an unknown identifier and stop.

int main(void) declares the program’s entry point. The OS calls main() when it runs your program. The int return type means the function will give back an integer to the calling process. The void in the parameter list explicitly says the function takes no arguments from the command line.

printf("Hello, World!\n") calls a library function that writes formatted text to standard output. The \n is an escape sequence for a newline character. It moves the cursor to the next line after printing.

return 0 sends the exit code to the OS. Zero means success. Any non-zero value signals that something went wrong, useful when your program is called from a shell script or CI pipeline that checks exit codes.

The braces { and } define the function body. Everything between them is executed when main() runs.

Variables, Data Types, and Basic Arithmetic

C is statically typed: every variable must be declared with a type before use, and the type cannot change. The six primary numeric types:

TypeTypical sizeRange / use
char1 byteSingle character or small integer (-128 to 127)
short2 bytesSmall integer (-32,768 to 32,767)
int4 bytesStandard integer (-2.1B to 2.1B on 32/64-bit)
long8 bytes (64-bit)Larger integer range
float4 bytesSingle-precision decimal (~7 significant digits)
double8 bytesDouble-precision decimal (~15 significant digits)

Declare a variable by naming its type, then its identifier:

int age = 21;
float gpa = 8.7;
char grade = 'A';

Basic arithmetic operators in C are +, -, *, /, and % (modulo). Integer division truncates: 7 / 2 evaluates to 3, not 3.5. To get decimal division, at least one operand must be a floating-point type: 7.0 / 2 gives 3.5.

For array operations in C, knowing these types matters because an int array and a char array occupy different amounts of memory per element, a fact that shows up in pointer arithmetic questions.

The Compilation Pipeline: From Source to Executable

Running gcc hello.c -o hello looks like a single step, but GCC actually runs four distinct stages. The GCC documentation covers each stage’s options in detail; here is the practical summary.

  1. Preprocess — The preprocessor (cpp) handles all #include, #define, and #ifdef directives. It produces an expanded .i file with all headers pasted in and all macros substituted. Run this step alone with gcc -E hello.c -o hello.i.

  2. Compile — The compiler translates the preprocessed C source into assembly language for the target CPU architecture. Output is a .s file. Run with gcc -S hello.i -o hello.s.

  3. Assemble — The assembler (as) converts the assembly language into machine code, producing an object file (.o). Object files are not yet runnable; they contain relocatable machine code with unresolved symbol references. Run with gcc -c hello.s -o hello.o.

  4. Link — The linker (ld) combines one or more object files with library code (including the standard C library, libc) to produce a complete executable. Symbol references are resolved at this stage. Run the full pipeline with gcc hello.c -o hello.

Understanding the pipeline helps when reading error messages. A “undefined reference to printf” error comes from the linker (stage 4), not the compiler. It means the standard library was not linked. An “implicit declaration of function” warning comes from the compiler (stage 2). It means a header was missing at preprocess time.

A Worked Program: Sum and Area

Sum of two numbers

#include <stdio.h>

int main(void) {
    int a, b, sum;
    printf("Enter two integers: ");
    scanf("%d %d", &a, &b);
    sum = a + b;
    printf("Sum = %d\n", sum);
    return 0;
}

Key points:

  • scanf("%d %d", &a, &b) reads two integers from standard input. The & operator passes the memory address of each variable so scanf can write the values directly into them.
  • %d is the format specifier for a decimal integer. For float, use %f; for double, use %lf; for char, use %c.

Area of a circle

#include <stdio.h>

int main(void) {
    float radius, area;
    const float PI = 3.14159;
    printf("Enter radius: ");
    scanf("%f", &radius);
    area = PI * radius * radius;
    printf("Area = %.2f\n", area);
    return 0;
}

Key points:

  • const float PI = 3.14159 declares a named constant. The compiler treats any attempt to reassign PI as an error.
  • %.2f in the format string rounds the output to two decimal places. For radius 5, the output is 78.54.

Once you’re comfortable with these patterns, the logical next step is working through string operations like palindrome checking in C, which introduces character arrays and loop-driven traversal.


The compilation pipeline you learned here (where typed structs and header declarations govern what the linker can resolve) is the same mental model that makes working with LLM APIs less opaque. Modern AI APIs pass tokens as integer IDs through typed JSON schemas. That typed-language background cuts the time spent parsing API docs compared to starting cold. TinkerLLM is a hands-on sandbox at ₹299 where you can apply that reasoning to actual LLM calls, a natural next step once the C basics are solid.

Primary sources

Frequently asked questions

Is C still relevant for placement interviews in 2026?

Yes. Pointer reasoning, memory layout, and pass-by-value versus pass-by-pointer questions appear in product-company technical rounds and semiconductor firm interviews. Service-tier companies such as TCS and Infosys include basic C programs (swap, palindrome, prime check) in their online tests.

Which compiler should I use to learn C?

GCC works on Linux natively and on Windows via MinGW or WSL2. Clang is the default on macOS. For zero-setup practice, GDB Online at onlinegdb.com runs full C programs in a browser with a built-in debugger, no installation needed.

What does return 0 mean at the end of main?

It sends an exit code of 0 to the operating system, which is the Unix/Linux convention for the program finished without errors. A non-zero return value signals a failure condition. Shell scripts and CI pipelines rely on this exit code to decide whether to continue.

What is the difference between C and C++?

C++ is a superset of C that adds classes, templates, and the STL. Most valid C code also compiles as C++, but C++ has additional keywords and stricter type-checking. For placement DSA questions about pointers and arrays, C is sufficient. C++ adds STL containers like vector and map, which some product-company interview questions expect.

What does #include <stdio.h> actually do?

It is a preprocessor directive. Before compilation starts, the preprocessor finds the stdio.h header file and pastes its content into your source file. That content includes the function declarations for printf(), scanf(), and related I/O functions. Without it, the compiler sees those names as undefined symbols and errors out.

Build AI projects

A self-paced playground for building with LLMs.

TinkerLLM is FACE Prep's sister property. A guided environment for shipping real LLM applications, the kind of project that earns a paragraph on your resume, not a line.

Try TinkerLLM (₹299 launch)
Free AI Roadmap PDF