02 Computer and C Programming Language
02 Computer and C Programming Language
Software
Some Tips
➢ Learn by doing. Always play with the code while learning
➢ Seek out more online resources. There’s a wealth of content
➢ Don’t just read the sample code. Tinker with it!
➢ Take breaks when debugging
• Office
• Email, Instant messaging, Video chat
• Electronic health records
• Medical imaging
• Cloud computing
• Robots
• Internet TV
• Game programming
• Input Unit
• Output Unit
• Memory Unit
• Database
• Files
• Records
• Fields
• Characters
• Bit
4 February 2025 Programming for Engineers (C language) NV Binh 10
1 Introduction to Computer and C language
Programming Languages
Various programming
languages
LOAD BASEPAY
ADD OVERPAY
STORE GROSSPAY
Preprocessor
Phase 2Preprocessor Disk program processes
the code
Creates
object code
Phase 3 Compiler Disk and stores on
disk
Puts program in
Phase 5 Loader memory
Primary memory
Takes each
instruction
Phase 6 CPU and executes it
storing
new data values
1 /* A first C Program*/
2 #include <stdio.h>
3 int main()
4 {
6 return 0;
7 }
Line 4: {
▪ This opening bracket denotes the start of the program.
Line 6: }
▪ This closing bracket denotes the end of the program.
• \n new line
• \t horizontal tab (⋲ 6 spaces)
• \r carriage return
• \a alert
• \\ backslash
• \” double quote
C operation Algebraic C
Addition(+) f+7 f+7
Subtraction (-) p-c p-c
Multiplication (*) bm b*m
Division (/) x/y x/y
Modulus (%) r mod s r%s
➢ Highest to lowest
• ()
• *, /, %
• +, -
•=
4 February 2025 Programming for Engineers (C language) NV Binh 32
1 Introduction to Computer and C language
Precedence Order
Algebra:
z = pr%q+w/x-y
C:
z = p * r % q + w / x – y;
Precedence: 6 1 2 4 3 5
C:
a * ( b + c ) + c * ( d + e );
Precedence: 3 1 5 4 2
➢ Equality operators
• == equality
• != difference
➢ Relational operators
•< less than
•> greater than
• <= less than or equal to
• >= greater than or equal to
• ++ i++ post-increment
▪ i = 1;
▪ j = i++;
▪ (i is 2, j is 1)
• -- --i pre-decrement
• -- i-- post-decrement
4 February 2025 Programming for Engineers (C language) NV Binh 38
1 Introduction to Computer and C language
Example
c %= a;
printf("Line 6 - %= Operator Example, Value of c = %d\n", c );
c <<= 2;
printf("Line 7 - <<= Operator Example, Value of c = %d\n", c );
c >>= 2;
printf("Line 8 - >>= Operator Example, Value of c = %d\n", c );
c &= 2;
printf("Line 9 - &= Operator Example, Value of c = %d\n", c );
c ^= 2;
printf("Line 10 - ^= Operator Example, Value of c = %d\n", c );
c |= 2;
printf("Line 11 - |= Operator Example, Value of c = %d\n", c );
}