5. Writing a Program in C (Lesson)
Writing a Program in C
In this module, we move from the basics to actually compiling and running our first complex programs.
Steps to Run a C Program
- Writing: Use a text editor (VS Code, Vim, etc.)
- Preprocessing: Handled by the compiler (expanding headers).
- Compilation: Converting C code to Assembly.
- Assembly: Converting Assembly to Machine Code.
- Linking: Combining libraries.
Example: User Input
#include <stdio.h>
int main() {
int age;
printf("Enter your age: ");
scanf("%d", &age);
printf("You are %d years old.\n", age);
return 0;
}
Check the Lecture Slides tab to see the visual presentation for these steps.