Introduction To C Programming
Introduction To C Programming
Introduction To C Programming
Programming
Introduction
Books
C is used:
System software Compilers, Editors, embedded systems
data compression, graphics and computational geometry, utility
programs
databases, operating systems, device drivers, system level
routines
there are zillions of lines of C legacy code
Also used in application programs
Software Development Method
Requirement Specification
Problem Definition
Analysis
Refine, Generalize, Decompose the problem definition
Design
Develop Algorithm
Implementation
Write Code
Verification and Testing
Test and Debug the code
Development with C
Four stages
Editing: Writing the source code by using some IDE or editor
Preprocessing or libraries: Already available routines
compiling: translates or converts source to object code for a specific
platform source code -> object code
linking: resolves external references and produces the executable
module
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
Programming languages
High-level languages
Primary memory
Puts program in
Phase 5 Loader memory
Primary memory
Takes each instruction
Phase 6 CPU and executes it storing
new data values
Simple C Program
/* A first C Program*/
#include <stdio.h>
void main()
{
printf("Hello World \n");
}
Simple C Program
Line 1: #include <stdio.h>
C:
z = p * r % q + w / x y ;
Precedence:
1 2 4 3 5
Example
Algebra:
a(b+c)+ c(d+e)
C:
a * ( b + c ) + c * ( d + e ) ;
Precedence:
3 1 5 4 2
Decision Making
Checking falsity or truth of a statement
Equality operators have lower precedence than
relational operators
Relational operators have same precedence
Both associate from left to right
Decision Making
Equality operators
==
!=
Relational operators
<
>
<=
>=
Summary of precedence order
Operator Associativity
() left to right
* / % left to right
+ - left to right
< <= > >= left to right
== != left to right
= left to right
Assignment operators
=
+=
-=
*=
/=
%=
Increment/ decrement operators
++ ++a
++ a++
-- --a
-- a--
Increment/ decrement operators
main()
{
int c;
c = 5;
5
printf(%d\n, c); 5
printf(%d\n, c++); 6
printf(%d\n\n, c);
c = 5;
printf(%d\n, c); 5
6
printf(%d\n, ++c); 6
printf(%d\n, c);
return 0;
}
Thank You
Thank You