Concepts of Programming Language: Source Code, Object Code, executable code

You write source code for humans (.c), the compiler translates it to object code (.obj), and the linker finishes it into executable code (.exe), the only form a CPU can actually run.

9 min read · 9 cards · 2 checks

Read in: English · हिन्दी · ગુજરાતી


Theory

The program you are about to grow

This subject has one hero: the marks program. Today it can only print one line about one student. By the end of the syllabus it will store a whole class, compute grades, sort toppers, and live in neat functions.

But there is a problem to solve first. You will write it in C, which looks like mathematical English. And from BCA103 you already know the CPU runs only binary machine instructions.

Someone must translate. That someone, and the three forms your program takes on the way, is this lesson.

Theory

Recipe, prepped tray, served dish

A recipe card in your handwriting is for humans: anyone who reads the language can follow or improve it. That is source code. A kitchen then preps it into trays of chopped, measured ingredients, useless to eat, but machine-ready: object code. Finally the counter assembles trays plus standard sides (bread, chutney nobody re-makes) into a served dish: the executable. Only the dish can be eaten; only the executable can be run.

Practical

marks.c, the marks program, day one

#include <stdio.h>

int main() {
    printf("Riya scored 78 marks\n");
    return 0;
}

This example runs in Gri-Learn on the web, where you can edit it and see the output.

Theory

The three forms, formally

That file above is plain text you could read aloud. Watch its journey:

marks.c → [compiler] → marks.obj → [linker] → marks.exe

  • Source code (marks.c): the program as humans write and read it.
  • Object code (marks.obj): the compiler's machine-language translation, but incomplete: the code for printf is not inside it, only a note saying "printf needed here".
  • Executable code (marks.exe): the linker joins your object code with the library's ready-made code (like printf's). This file the CPU runs directly.

Quiz

Which of the three files can the CPU run directly?

  1. marks.exe, the executable
  2. marks.c, the source code
  3. marks.obj, the object code
  4. All three run equally well
Show the answer

marks.exe, the executable

Only the executable is complete machine language with every reference resolved. Source is human text the CPU cannot interpret, and object code, though translated, still has holes where library code (printf) must be linked in. "Why can't object code run?" is the sharper exam follow-up: unresolved references.

Think first

Think it through

Your friend edits marks.exe in Notepad hoping to change 78 to 95, and sees only garbage symbols. Why? And which file SHOULD they edit?

Show the answer

The executable is binary machine instructions, not text: Notepad renders those bytes as garbage. Changes belong in the source (marks.c), the human-readable form, followed by recompiling to regenerate the .obj and .exe. One-way street: source compiles down to executable; executables do not politely turn back into source.

Watch out

Where marks leak

Writing "the compiler runs the program": it only translates; running is the CPU's job, later. Claiming object code is runnable: it is machine language but unlinked, printf's body is still missing. And do not swap the order in the pipeline diagram: compiler first, linker second. Exams award the diagram source → compiler → object → linker → executable as its own marks.

Theory

You will watch this pipeline daily

Every time you press "compile and run" in a C IDE this whole pipeline fires: translate, link, execute. When the next lesson explains WHY C organises programs into clean blocks, and the one after names the tools (editor, compiler, interpreter), you will already own the map. The marks program grows from here, one lesson at a time.

Summary

Key takeaways

  • Source code (.c): the program in human-readable text, written in C.
  • Object code (.obj): the compiler's machine translation, incomplete until linked.
  • Executable (.exe): linker joins object + library code; the only file the CPU runs.
  • Pipeline: source → compiler → object → linker → executable.
  • The compiler translates; it never runs anything.
  • Memory hook: recipe, prepped tray, served dish.

Study this properly

This page is the lesson to read. In Gri-Learn the same topic is a graded deck: the self-checks are scored and your weak topics are tracked. Free to start.

Start this topic

Already have an account? Sign in

More from Introduction to C language

Gri-Learn · syllabus-mapped B.C.A. lessons in English, Hindi and Gujarati

Concepts of Programming Language: Source Code, Object Code, executable code · Computer Programming and Programming Methodology (CPPM) · Gri-Learn