Basics of Programming
Mrs Sangeeta Bhandari
PG Department of Computer Science & IT
HMV, Jalandhar
Contents
Computer Programming Languages
Programming
Flowchart
Flowchart Symbols
Flowchart Symbols
Flow chart of the while loop :
Flow chart of the for loop:
The flow chart of the if statement:
The flow chart of the if…else statement:
The flow chart of the switch statement:
Flowchart for finding the sum of first five natural numbers ( i.e. 1,2,3,4,5):
Flowchart (Example):
Flowchart to find the sum of first 50 natural numbers.
Start
Read A, B
Is A > B
Print A
Print B
End
Yes
No
Flow Chart to find largest of two numbers:
Flowchart to find the largest of three numbers A,B, and C:
NO
LIMITATIONS OF USING FLOWCHARTS:
Flowchart (Exercise):
Computer Programming Languages:
Computer Programming Languages (Contd…):
Non-computational languages:
Machine language:
Machine language:
For example, an x86/IA-32 processor can execute the following binary instruction as expressed in machine language:
Binary: 10110000 01100001 (Hexadecimal: 0xb061)
Assembly Level Language:
Assembly Level Language
Example: Assembly language representation is easier to remember (more mnemonic)
mov al, 061h
This instruction means:
Move the hexadecimal value 61 (97 decimal) into the processor register named "al".
The mnemonic "mov" is an operation code or opcode, A comma-separated list of arguments or parameters follows the opcode;
Example (Adds 2 numbers):
name "add"
mov al, 5 ; bin=00000101b
mov bl, 10 ; hex=0ah or bin=00001010b
add bl, al ; 5 + 10 = 15 (decimal) or hex=0fh or
bin=00001111b
High-level language:
High-level language
Examples of HLL:
for example, Visual Basic wraps the BASIC language in a graphical programming environment.
Example (C program to add 2 numbers):
#include<stdio.h> //header files
Void main()
{
int a, b, c; // declaration of 3 variables
printf(“Enter two numbers:\n”);
Scanf(“%d”, &a); // read 1st number
Scanf(“%d”, &b); // read 2nd number
c=a+b; // compute the sum
printf(“Sum of 2 numbers is %d”, c); //print sum
}