You are on page 1of 12

COMPUTER PROGRAMMING

FOR ENGINEERING

1
Different Levels of
Computer Programming Languages
 What is Program?
 A computer program is a sequence of
instructions that are executed by a CPU. The CPU
(or processor) executes the instructions one by
one.
 The programming languages are broadly
classified as:
1. Low level languages

2. High level languages

2
Different Levels of
Computer Programming Languages
 Low level languages
 The low level language or the machine language is a system of
instructions and data executed directly by a computer's central
processing unit (CPU).
 In machine code, each instruction is simply a stream of binary
digits, or 0s and 1s.
 High level languages
 A high-level language is an advanced computer programming
language that isn't limited by the computer, designed for a
specific job, and is easier to understand. The programs are close
to human languages.

3
Comparison of the Levels of Languages
  Low Level High Level

Easy for the machine to The program should be


1
read and write .compiled or interpreted
Difficult for the Easy for human to read

2 programmer to write .and write


.syntax and programs
Occupies less memory Occupies more memory
3

Eg: Machine Language Eg: C Programming, C+


4
10001010 +,Fortran,JAVA
4
Algorithms and Flowcharts
 An Algorithm is a step-by-step procedure to solve any real
world problems. Algorithms are a fundamental part of
computing or solving any problem.
 Following are the keywords to be used with every
algorithm
 START: to begin an algorithm
 STOP/ END: to finish an algorithm
 STEP: activities done in that algorithm. An algorithm may
have multiple steps.
 ACCEPT / READ: to get the input from the user.
 DISPLAY / WRITE: to show the output to the user
5
Example-1
Algorithm to find the sum of two numbers
START
STEP 1: Accept the two numbers N1,N2
STEP 2: Find the sum, SUM = N1 + N2
STEP 3: Display the SUM
END

6
Example - 2
Algorithm to find the average of 10 marks
 START

STEP 1. Read the 10 subject marks.


STEP 2. Find the sum of all marks
STEP 3. Divide the sum by 10.
STEP 4. Write the average marks.
 END

7
Flow Charts
 Flow Charts are the pictorial representation of the step
by step procedure of solving a problem. Flowcharts used
to be a popular means for describing computer
algorithms.
 Some of the common symbols used in flowcharts
are shown below:

Terminator Process

Input / Output Decision

8
Example - 1
Flowchart to find the sum, average and product of
three numbers.

9
Example - 2
Flowchart to check the temperature is above or
below freezing point.

10
Questions
1. To accept basic salary, allowance and display the total salary.
Total salary=basic salary + allowance
2. To accept the temperature in centigrade and display it in
Fahrenheit.

F = C X 1.8 + 32

3. To accept P (principal amount), N (number of years), R (rate of


interest), calculate and display SI (simple interest).
Where SI= PNR / 100
4. To accept the radius of a circle and display its area, where
Area = πr2
5. To find the area of a triangle using the following formula.
Area= √ s(s-a)(s-b)(s-c) Where s = (a + b + c) / 2
11
Questions
6. To check the input number is positive or negative.

7. To read three numbers and find which is greater?

8. To accept the temperature in Fahrenheit and display it in


Centigrade.

C = F-32 / 1.8

9. To read the height of a person and display tall if the height is


greater than 180 cm otherwise display short.

12

You might also like