1 of 17

Introduction to Programming

2 of 17

Agenda

  • How does computing happen in a computer?
  • High-level Languages (HLL)
  • Introduction to C Language
  • Lifecycle of a C Program

3 of 17

HOW DOES COMPUTING HAPPEN?

4 of 17

Computing - Under the Hood

  • CPU
    • The workhorse under the hood of any computer
    • Carries out instructions given in a program
  • Memory
    • The place where data created and used by CPU is stored
  • Input Device
    • Used for providing inputs of the program
  • Output Device
    • Used for showing output of the program

5 of 17

It is all binary!

  • Instructions to CPU are expressed and understood ONLY IN BINARY (as a sequence of zeros and ones)
  • Data is stored and manipulated ONLY IN BINARY!

But….

Humans do not speak BINARY!

6 of 17

HIGH-LEVEL PROGRAMMING LANGUAGES

7 of 17

High Level Languages (HLL)

  • HLLs are languages that are used to give instructions to the computer by programmers
  • HLLs are written using normal alphabet of the English language
  • The language contains keywords that resemble some words from our natural language (e.g., for, do, while, if, etc.)

8 of 17

Some Popular High Level Languages

  • C language
    • One of the most popular programming languages
    • Used widely in high-performance systems like embedded systems, microcontrollers, etc
  • Java
    • Very popular language for developing enterprise software applications
  • Python
    • Powerful language used widely in AI and ML applications

9 of 17

Classes of Languages

  • Compiled languages
    • Compilation required to convert from high level to machine language
    • C, C++, Java, etc
  • Scripting languages (interpreted)
    • Compilation NOT required; an interpreter conveys appropriate instructions to the CPU dynamically
    • Python, shell script, etc.

10 of 17

LIFE CYCLE OF A C PROGRAM

11 of 17

Life Cycle of a C Program

HLL Instructions

Compile

Link

Execute

Programmer

Compiler

Linker

Operating System

12 of 17

Compilation

    • Whether program is written as per proper grammar and punctuation!

Syntax checking

    • The object file contains machine language instructions in binary

Conversion to object file

    • A program that takes a high level program as input and give object file as output

Compiler

13 of 17

Linking

Re-use

Writing a program that is self-contained for doing EVERYTHING is tedious

Programmers use pre-created “libraries” for implementing routing tasks

Linking

Linking is the process of integrating external programs that provide these reusable functions

A LINKER takes a set of object files as input and produces an executable as output

Execution

The operating system can now execute the “executable file”

14 of 17

Summary

Life Cycle

HLL Instructions

Compile

Link

Execute

Programmer

Compiler

Linker

Operating System

15 of 17

WHAT WE WILL EXPLORE

16 of 17

About the C Language

  • C language was created in early 1970s specifically for writing the code for Unix Operating System
  • C language is a compiled programming language
  • C language is considered to be highly portable because compilers are available for almost every hardware and processor architecture

17 of 17

Very Powerful Features

  • Provides very high performance
  • Provides great flexibility for system-level operations
    • Memory access via pointers
    • Storage / Disk access via system calls
    • Network programming via sockets
    • Inter-process communication via PIPES