You are on page 1of 24

Programming Fundamentals

What is Programming
________________ ?

Programming is the process of creating a set of instructions


that tell a computer how to perform a task.

Set of instructions Program

The Language which is used for the Interaction with the


computer is known as Programming Language.
What is Compiler
_____________ ?

HLL MinGW MLL

A compiler is a special program that translates a programming


language's source code into machine code.
Why Use Computer To Solve A
____________________________Problem ?

1. A Programmer’s job is to find the optimal algorithm


to solve a problem.
A set of well-defined instructions to
solve a particular problem.

2. Computer is not smarter than human but yes it’s


definitely faster.
Thought Process To Solve A Problem
__________________________
Step 1 : Define or Understand the Problem
Step 2 : Find a Solution
Step 3 : Write down the Rough sketch of solution
Step 4 : Code in High level language
Step 5 : Convert Written Code into Low level language
Problem Solution Rough
Sketch
Of
LLL HLL Solution
FlowCharts
___________:
Diagram to represent the different steps of the process
in sequential order.

Graphical Representation of an Algorithm.


Components Of FlowChart
___________________ ?

Start / Exit Decision

Input / Output Arrows

Process
Draw FlowChart For Multiplication Of Two Numbers
________________________________
Start

A,B Input A,B

Multiplication = A x B
M=AxB

Print M

Exit
PseudoCode :
____________
An informal way of Programming Description that does not
require any strict programming language syntax.

Generic Way of representing an algorithm in textual form.


PseudoCode For Multiplication Of Two Numbers
______________________________

1. Start Program
2. Get A and B
3. Calculate : M = A x B
4. Print M
5. End Program
Questions :
Sum Of 2 Numbers
_____________
Input FlowChart PseudoCode
Start
First number, A
1. Start Program
Second number, B
Input A,B
2. Get A and B
Output 3. Calculate : Sum = A + B
Sum of A & B Sum = A + B 4. Print Sum
5. End Program
Print Sum

Exit
Calculate Simple Interest
__________________
Formula FlowChart PseudoCode
Start
SI = Principal * Rate * Time
100 1. Start Program
Input P,R,T 2. Get P, R, T
Input
3. Calculate : SI = PRT / 100
Principal, P
SI = (P*R*T)/100
4. Print SI
Rate, R
5. End Program
Time, T
Print SI
Output
SI = PRT / 100 Exit
Average Of Three Numbers
___________________
Formula FlowChart PseudoCode
Start
AVG = A + B + C
3 1. Start Program
Input A,B,C
Input 2. Get A, B, C

First number, A 3. Calculate : AVG = (A+B+C)/3


AVG = (A+B+C)/3
Second number, B 4. Print AVG

Third number, C 5. End Program


Print AVG
Output
Average of A, B & C Exit
Find Max Of 3 Numbers
________________ PseudoCode
1. Start Program
Input FlowChart 2. Input A,B,C

First number, A 3. If A>B do,


start
If A>C do,
Second number, B
Input A,B,C print A
Third number, C
yes no Else
Is A>B ?
print C
Output no no Else
Is A>C ? Is B>C ?
Maximum of 3 If B>C do,
yes yes
print A
print C
print B
print B
Else
exit print C
4. End Program
Sum of N Natural Numbers
___________________
N=5
Sum = 1+2+3+4+5 = 15

N=9
Sum = 1+2+3+4+5+6+7+8+9 = 45
Sum of N Natural Numbers
___________________
Input Logic N=4
Number, N = 4 Sum = 1+2+3+4 = 10

Variable, V = 1 2 3 4 V = 1 to V < = N
Output
Sum of N natural number Sum = Sum + V Sum = 0
Sum = 1
Sum = 3
Sum = 6
Sum = 10
FlowChart
start
PseudoCode
Input N 1. Start Program
2. Input N
Let V=1, Sum=0
3. Let, V = 1 and Sum = 0
4. While V<=N do,
yes Sum = Sum + V
Is V<=N ? Sum = Sum + 1
V=V+1
no V=V+1
print Sum 5. Print Sum
6. End Program
exit
Check Number is Odd or Even
_____________________
Input Logic
Number, N = 4
N=4

Output N%2=0
N is Even or Odd 4%2=0 3%2=1
6%2=0 5%2=1

Even : N % 2 = 0 Odd : N % 2 = 1
FlowChart

PseudoCode
start
1. Start Program
Input N 2. Input N
3. If N % 2 = 0 do,
yes no
Is N%2==0 ? Print Even
else
print Even print Odd
Print Odd
6. End Program

exit
Check Number is Prime or Not
_____________________
Input Logic
Number, N = 4

Output
N is Prime or Not
FlowChart start

Input N PseudoCode

Let div = 2 1. Start Program


2. Input N

Is div<=N ? 3. If N % 2 = 0 do,
Print Even
yes
no else
Is N%div==0 ? div = div + 1
Print Odd
no
6. End Program
Print Prime print Not Prime

exit
HomeWork
__________
Question 1: Print the Even numbers between 9 and 100.

Question 2: Calculate the area of circle.

Question 3: Find Factorial of a number.

Question 4: Print Counting from 1 to N.

Question 5: Calculate the area of Triangle.

You might also like