Professional Documents
Culture Documents
Lecture03 HelloWorld by Asma
Lecture03 HelloWorld by Asma
Introduction to C code
Asma Majeed
1
Write
Agenda
To be followed in today’s lecture
Compile and Link
Execute
Types of Errors
3
Coding
Compile Execute
Write it
it it
5
Compiling & Linking
• Translator
• Translate code into machine readable form
• Reads translation unit and write the resulting Object Module(a code in
machine language) to a file
• Linking
• Assembles Functions like input/output and mathematical
library functions into final executable form
6
Program Execution
• OS uses run command to load program into primary
memory(Loader) and execute it
7
Basic Structure of a .C Program
Q. What does this code output (print to the user) when you run (execute) it?
• Preprocessor Directives
• Main function
• {
• Statements
• } curly braces
{ { { {
return 0;
} } } }
}
Fundamentals of computer programming 12
Statement cont…
• Statement has two parts :
• Declaration
• The part of the program that tells the compiler the names of memory
cells in a program
• Executable statements
• Program lines that are converted to machine language instructions
and executed by the computer
statement(s);
} End of segment