Beruflich Dokumente
Kultur Dokumente
Basics of Programming
Introduction to Computer
• What is Computer?
– Electronic Machine that takes input, Process it and
generate desired output quickly
Use of Computer
Components of Computer
Computer Programming Basics
• Computer programs are a detailed set of
instructions given to the computer.
• Generality
– Should solve all problems of a particular type
• Effectiveness
– Should take less time
• Input & output
– Must precise inputs and generate imtermediate as
well as final output
Algorithm to find addition of two
numbers
• Step 1: START
• Step 2: Read Values of A & B
• Step 3:Compute
Sum=A+B
• Step 4: Display Sum
• Step 5: Stop
Algorithm to find area of circle
• Step 1: START
• Step 2: Define constant Π=3.142
• Step 3: Read radius of circle r
• Step 4:Compute
Area= Π *r*r
• Step 5: Display Area
• Step 6: Stop
Algorithm to find maximum number
between two
• Step 1: START
• Step 2: Read Values of A & B
• Step 3: if (A>B)
Display A
else
Display B
• Step 4: STOP
Algorithm to swap two numbers
• Step 1: START
• Step 2: Read Values of A & B A B
• Step 3: temp=A
• Step 4: A=B
A B Temp
• Step 5: B=temp 10 20
• Step 6: STOP 10
20
20
20
10
10
20 10 10
Algorithm Logic
• Sequential Flow
• Conditional Flow
• Repetitive Flow
Sequential Flow
•Random Access
•Fast
•Costly than Sam
•Volatile
C programming Environment
Editor
• An editor used to write a c program
• E.g. notepad, notepad++, gedit
• C programs are written in human readable
source code that is not directly executable by
a computer
Preprocessor
• C Preprocessor is just a text substitution tool
and it instructs the compiler to do required
pre-processing before the actual compilation.
• # include<stdio.h>
– Includes standard input output file in your code
Compiler
• Machine Language
– Language of 0’s and 1’s understood by computer
– Lowest level directly executed by hardware
–
Translates
Linking
• The object code is combined with required
supporting code to make an executable
program
Loading
• Loader loads executable code into main
memory
Main
.exe CPU
Memory
Executable file
Execution
• Executes or Run the C Program
C programming Environment
Test Ur understanding
• The brain of any computer system is
a. ALU
b. Memory
c. CPU
d. Control Unit
• (c)