Programming in C
Concepts of Programming Languages
1. Language Evaluation Criteria
How to judge a programming language:
Easy to read
Easy to write
Reliable (few errors)
Runs efficiently
Works well on different computers
Simple and consistent rules
Powerful to express ideas
2. Language Design
How a language is made:
Rules for writing code (syntax)
What the code means (semantics)
Aim for easy, clear, and efficient coding
3. Language Categories
Types of programming languages:
Low-level: Close to machine code (Assembly, Machine language)
High-level: Easier for humans (C, Java, Python)
By style:
o Imperative (step-by-step commands)
o Functional (using functions)
o Object-Oriented (using objects)
o Logic-based (using logic rules)
4. Implementation Methods
How code runs on a computer:
Compiled: Code turned into machine language before running
(fast)
Interpreted: Code runs line-by-line (slower but easier to test)
Mixed: Compile to intermediate code, then run (like Java)
5. Programming Environments
Tools to help programmers:
Editors and IDEs (write code easily)
Debuggers (find and fix errors)
Compilers and interpreters (run code)
Version control (track code changes)
Profilers (check program speed and memory)
REPL (interactive coding)
Overview of C Language
1. History of C
Developed by Dennis Ritchie in 1972 at Bell Labs.
Created to develop the UNIX operating system.
Based on earlier languages like B and BCPL.
2. Importance of C
Powerful & Fast – Closer to hardware, great for system-level
programming.
Portable – Code can run on different systems with little change.
Foundation for other languages – Like C++, Java, Python.
Used in operating systems, compilers, embedded systems,
etc.
3. Basic Structure of a C Program
#include <stdio.h> // Header file
int main() { // Main function - program starts here
printf("Hello World"); // Output statement
return 0; // Exit the program
}
Parts:
#include <stdio.h> – Tells the compiler to use standard I/O functions.
main() – Starting point of the program.
printf() – Function to display output.
return 0; – Ends the program successfully.
4. Steps to Execute a C Program
1. Write Code – Using a text editor or IDE.
2. Save File – With .c extension (e.g., program.c).
3. Compile – Convert code to machine language using a compiler
(e.g., gcc program.c).
4. Link – Combine compiled code with libraries.
5. Run/Execute – Run the final program (./a.out in Linux).