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

તમે માણસો માટે source code લખો છો (.c), compiler એને object code માં translate કરે છે (.obj), અને linker એને executable બનાવી દે છે (.exe), એ જ એક રૂપ જે CPU ખરેખર ચલાવી શકે છે.

9 min read · 9 cards · 2 checks

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


Theory

એ program જેને તમે મોટો કરવાના છો

આ subject નો એક hero છે: marks program. આજે એ એક student વિશે ફક્ત એક line print કરી શકે છે. Syllabus પૂરો થતાં થતાં એ આખો class store કરશે, grades કાઢશે, toppers sort કરશે, અને ચોખ્ખા functions માં રહેશે.

પણ પહેલાં એક problem ઉકેલવાની છે. તમે એને C માં લખશો, જે mathematical English જેવી દેખાય છે. અને BCA103 થી તમે જાણો છો કે CPU ફક્ત binary machine instructions ચલાવે છે.

કોઈએ translate કરવું પડશે. એ કોણ છે, અને રસ્તામાં તમારો program કયા 3 રૂપ લે છે, એ જ આજનો lesson છે.

Theory

Recipe, સમારેલી tray, પીરસેલી dish

તમારા હસ્તાક્ષરવાળું recipe card માણસો માટે છે: ભાષા જાણનાર કોઈ પણ એને વાંચે, follow કરે, સુધારે. આ જ source code છે. પછી kitchen એને સમારેલી, માપેલી ingredients ની trays માં prep કરી દે છે, ખાવા લાયક નહીં, પણ machine-ready: object code. છેલ્લે counter trays અને standard sides (જે bread-chutney કોઈ ફરી બનાવતું નથી) જોડીને dish પીરસે છે: executable. ખવાય ફક્ત dish; ચલાવાય ફક્ત executable.

Practical

marks.c, marks program નો પહેલો દિવસ

#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

ત્રણેય રૂપ, બરાબર

ઉપરની file સાદું text છે જે તમે બોલીને વાંચી શકો. હવે એની સફર જુઓ:

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

  • Source code (marks.c): program એવો જેવો માણસો લખે-વાંચે છે.
  • Object code (marks.obj): compiler નું machine-language translation, પણ અધૂરું: printf નો code એની અંદર નથી, ફક્ત એક note છે કે "અહીં printf જોઈશે".
  • Executable (marks.exe): linker તમારા object code ને library ના તૈયાર code (જેમ કે printf ના) સાથે જોડી દે છે. આ જ file CPU સીધી ચલાવે છે.

Quiz

3 files માંથી CPU કઈ સીધી ચલાવી શકે?

  1. marks.exe, executable
  2. marks.c, source code
  3. marks.obj, object code
  4. ત્રણેય સરખી ચાલે છે
Show the answer

marks.exe, executable

ફક્ત executable પૂરી machine language છે જેની દરેક reference resolve થઈ ચૂકી છે. Source માણસોનું text છે જે CPU સમજતું નથી, અને object code translate થઈને પણ અધૂરો છે, એમાં library code (printf) નાં કાણાં બાકી છે. ધારદાર follow-up exam પૂછે છે: "object code કેમ ન ચાલે?": unresolved references.

Think first

વિચારીને જુઓ

તમારો મિત્ર Notepad માં marks.exe ખોલીને 78 ને 95 કરવા માગે છે, અને એને ફક્ત garbage symbols દેખાય છે. કેમ? અને એણે કઈ file edit કરવી જોઈએ?

Show the answer

Executable એ binary machine instructions છે, text નહીં: Notepad એ bytes ને garbage તરીકે બતાવે છે. ફેરફાર source (marks.c) માં થાય, માણસોવાળા રૂપમાં, અને પછી recompile કરીને નવો .obj અને .exe બને. રસ્તો one-way છે: source નીચે ઊતરીને executable બને છે; executable સભ્યતાથી પાછો source નથી બનતો.

Watch out

Marks ક્યાં કપાય છે

"Compiler program ચલાવે છે" લખવું: એ ફક્ત translate કરે છે; ચલાવવું CPU નું કામ છે, પછી. Object code ને runnable કહેવો: એ machine language છે પણ unlinked, printf ની body હજી ગુમ છે. અને pipeline ના diagram માં order ન બદલો: પહેલા compiler, પછી linker. source → compiler → object → linker → executable વાળો diagram exam માં પોતાના અલગ marks લાવે છે.

Theory

આ pipeline તમે રોજ જોશો

C ના IDE માં જ્યારે પણ તમે "compile and run" દબાવશો, આ આખી pipeline ચાલશે: translate, link, execute. આગળનો lesson કહેશે કે C programs ને ચોખ્ખા blocks માં કેમ રાખે છે, અને એના પછીનો tools નાં નામ આપશે (editor, compiler, interpreter), ત્યાં સુધી નકશો તમારી પાસે હશે. Marks program અહીંથી જ મોટો થવા લાગે છે, દરેક lesson માં થોડો.

Summary

Key takeaways

  • Source code (.c): માણસો વાંચી શકે એવા text માં program, C માં લખેલો.
  • Object code (.obj): compiler નું machine translation, link થાય ત્યાં સુધી અધૂરું.
  • Executable (.exe): linker object + library code જોડે છે; CPU ફક્ત આ જ ચલાવે છે.
  • Pipeline: source → compiler → object → linker → executable.
  • Compiler translate કરે છે; ચલાવતો ક્યારેય નથી.
  • Memory hook: recipe, સમારેલી tray, પીરસેલી 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