Skills Needed in
Programming
I'm not going to claim that programming
is easy, but I am going to say that it is not
hard for the reasons people usually assume
it is. Programming is not a deeply
theoretical subject like Chemistry or
Physics; you don't need an advanced
degree to do well at it.
There are important principles of Computer
Science, but it's possible to get a degree
after studying them and to have only vague
ideas of how to apply them to practical
programming.
There
are
plenty
of
successful programmers who don't have
Computer Science degrees.
What we need?
(1) attention to detail,
(2) stupidity,
(3) good memory,
and
(4) an ability to think abstractly, and on
several levels.
Programming Language
A programming language is a humanreadable lexicon and grammar that a
programmer uses to instruct a
computer how to operate.
Programs written in a programming
language have to be translated into
machine code, usually by a translator
program (Assembler/ Interpreter/
Compiler).
Programming Language (contd…)
Machine code consists of multiple
lower-level instructions which the
computer can actually understand. Use
of a programming language allows
programmers to work at a higher level
than machine code (which is not
human-readable)
Language Generations
The following are some of the ways that people
have categorized different computer
programming language generations:
1st Generation:
Machine language
Operations in op-codes
Operands
Numerical values
Register number
Memory location address
2nd Generation: Assembly Language
A mnemonic system for representing Programs
Mnemonic:
More descriptive
Enabling
easy to remember
programming without tables
Things are mnemonic
Op-codes
in mnemonic names
Registers in mnemonic names
Memory locations in mnemonic names of the
programmer’s choice (Identifiers)
2nd to 1st
One-to-one correspondence between machine
instructions and assembly instructions
Inherently machine-dependent
Converted to machine language by a program
called an assembler
Thing are easier to remember, yes.
But programmer still needs to think like the
machine!
Third Generation Language
Uses high-level primitives
Similar to Pseudo-codes (or Algorithms)
Machine independent (mostly)
Each primitive corresponds to a short
sequence of machine language instructions
Converted to machine language by a
program called Compiler / Interpreter
Examples: FORTRAN, COBOL, BASIC
Fourth Generation Language
4GL or fourth-generation language is
designed to be closer to natural language
than a 3GL language. Languages for
accessing databases are often described as
4GLs.
Fifth Generation Language
5GL or fifth-generation language is
programming that uses a visual or graphical
development interface to create source
language that is usually compiled with a 3GL or
4GL language compiler. Microsoft, Borland,
IBM, and other companies make 5GL visual
programming
products for
developing
applications.
Compilers vs. Interpreters
Compilers:
Compile
several machine instructions into
short sequences to simulate the activity
requested by a single high-level primitive
Produce a machine-language copy of a
program that would be executed later.
Interpreters:
Execute
the instructions as they were
translated
The Evolution
Programming in C
Why learn to program in C?
1. Practicality.
Many, many companies/research projects do
all their programming in C.
Many,
many existing programs are written in
C, and you might be the one chosen to modify a
C program.
2. It is an industry standard.
3. It looks good on your resume.
Why learn to program in C?
4. Concepts.
C is occasionally called a "low-level," high level
language. The semantics of C often mimic what actually
occurs in the machine code. (or assembly language, if
you prefer to think of it in that way).
Due to the low level nature of C, the programming
constructs that it provides to the programmer (such
as pointers) are essential to know. Understanding these
concepts and constructs may allow you to be a better
programmer; one who can write better code, and code
that runs faster. Please note that this is true, even if you
only write Java code for the rest of your life!
Basics of Programming in ‘C’
• General organization of ‘C’ programs
• ‘C’ function libraries
How to compile and execute C programs
• On Windows, with Visual Studio, Turbo C
• On Linux/Unix with GCC / cc
Brief History of C
‘C’ was developed by Dennis Ritchie at Bell
Labs (1969 – 72) from two previous
programming languages, BCPL and B
• Support Linux/UNIX/ Mac/ Windows operating
system
• Successor to B and BCPL
Strongly typed language
Dynamic memory allocation
User defined data structures
History (Cont…)
Used
to develop UNIX
Used to write modern operating
systems
Hardware independent (portable)
By late 1970's C had evolved to
"Traditional C"
Standardization
Many
slight variations of C existed, and
were incompatible
Committee formed to create a
"unambiguous, machine-independent"
definition
Standard created in 1989, updated in
1999
The Modern C Language
C is a programming language that was invented to be
a low-level language that would facilitate more easily
describing/writing operating system code.
It is general purpose.
The code itself is rather compact.
C is a procedural language (also called
a functional language). This distinguishes it from (later
invented) object-oriented languages.
C++ is the successor to C
• Simplifies grouping of functions and related data
Anatomy of C Program
A collection of functions
Receive a set of parameters
Declare local variables
Carry out processing
Return a value
main( ) function
Called to start the program
C libraries
Most programs are not built from scratch
Rely on pre-existing collections of
functions
e.g.
the Standard C library
Header (.h) files describe functions in these
collections
e.g. accessed through #include statements
C
programs consist of pieces/modules called functions
A
programmer can create his own functions
Advantage:
the programmer knows exactly how it works
Disadvantage: time consuming
Programmers
will often use the C library
functions
Use
these as building blocks
Avoid
If
re-inventing the wheel
a pre-made (predefined) function exists, generally best
to use it rather than write your own
Library functions carefully written, efficient, and portable
A C function definition
return_type function ( parameter_list )
{
local_variable_declarations;
statements;
}
Each function has a type
Each function argument has a type
Each local variable has a type
A simple C program
/* C code is stored in a file with .c extension */
#include <stdio.h>
int main()
{
printf(“Hello, I am a program\n”);
return 0;
}
C Program: Source to Execution
The standard way to generate and eventually execute a
program is much the same for all high level languages.
In a diagram it appears as
Once
we have machine code,
Basics of a Typical C Program Development
Environment
• Phases of C Programs:
1. Edit
2. Preprocess
3. Compile
Editor
Disk
Preprocessor
Disk
Compiler
Disk
Compiler creates
object code and stores
it on disk.
Linker
Disk
Linker links the object
code with the libraries
Primary Memory
4. Link
5. Load
Program is created in
the editor and stored
on disk.
Preprocessor program
processes the code.
Loadear
Disk
6. Execute
Loader puts program
in memory.
..
..
..
Primary Memory
CPU
..
..
..
CPU takes each
instruction and
executes it, possibly
storing new data
values as the program
executes.
Basic Structure of a ‘C’ Program
[ documentation section ]
Preprocessor
macro directive
include directive
UDF prototype declaration section;
Global variable declaration section;
main()
{
local variable declaration section;
body of main function
[ return [ value ] ];
}
UDF1 definition
{
[ local variable declaration
section; ]
body of UDF1 function
[ return [ value ] ];
}
UDF2 definition
{
[ local variable declaration
section; ]
body of UDF1 function
[ return [ value ] ];
}
.
.
.
Next Lecture
Basic structure of a C-Program (to be contd..)
Character set
Data Types
Constants
Identifiers
Variables and Variable Names
Expressions
© Copyright 2025 Paperzz