h
H
m
c
p
r
t
i
/
v
e
w
o
l
u
g
n
a
INTRODUCTION TO PROGRAMMING
-
-
-
C= A+B
Print C
Programmer : a program is set of instruction ( STATEMENT) feed into computer to make it
perform a specific task
The program to perfume a task which could vary from drawing a picture , printing the result an
output screen or some of two numbers
The programming languages are written in English which a computer does not understand
A program Witten in English language in high level language that language converted into low
level language after converted the low level language the computer can understand.
E.g. High level language
Input A
Input B
Types of programming languages
into low level language with the help of complier or interpreter
High level language :
program’s written in
high level language
must be translated
Compiler: a compiler translates a entire program from high level into low level first then if
the program is error free , it is executed
Interpreter: it translates a program into low level language line by line , if the first line is
found to be error free in is converted into low level language the same process is repeated
for all the lines
Note: compiler much faster when compiled with a interpreter
E.g. 1.input ‘enter the mark ‘- M 1
2. Input ‘enter the mark ‘- M 2
3. TOTAL = M1=M2
4. PRINT @ TOTAL IS “Total “
5. End
Assembly language: before the invention of high level language, the programmers use to write
program’s in the assembly language .In assemble language, assembler is required the translate the
program in to low level language
E.g.:
MOV b1, 02 MOV, ADD, INT are mnemonics
Mov c1, 03
Add b1, c1
Mov d1, b1
Mov ah, 02
Int 21
Int 20
Algorithem
Co efficient mean value of x
Step 1
Get the value for a,b,c
A= value of x2
B= value of x
C = constant term
Step 2
∆ = b+b –4 *a *c
Step 3 check the value for ∆
If ∆ >0
-b+sqrt( b –4*a*c) /(2*a)
Result 2 = -b-sqrt(b*b-4*a*c) / (2*a)
Display the value of result 1 and 2
If ∆=0
Result –b /(2*a)
Display the value for result
If ∆ <0
DISPLAY THE MASSGE AS “ IMAGARNY SOLUTION”
Types of Varibale
There are two types of variable
1. Numerical
2. Non numerical variables
Numerical
1. Integer
2. Real number
Non- numerical Variables
1. Charcter
2. Sting
The variable that store numeric data or numbers are called as numeric variable
Integers : are whole numbers it do not have fractional part eg. ( 0.99)
Real numbers: have fractional parts eg. 5.5
Non numeric Variables
Characters: character variables can be stores any letter or special symbols $ sign @ sign etc. character is
enclosed in single codes Example ‘ a’
String variables are enclosed within double code example “ a
Modular approach methods
In a programmer have different complex tasks. That complex task can be dived into different modules
this is like that human beings do all the time. For eg : preparing a cup of tea.
Task 1 , boil the water in pot and heat
Task 2 pour the hot water after boiling into the cup
Task 3 put milk and tea leaves , sugar in the cup
Task 4 stair it well for using
Preparing a cup of tea is simple task , we broke it down into four steps
But even a simple programme can have thousands of statements , complex program, may have millions
of statements
One of the most important things a programmer needs to manage the complexity of a program,. This
can be done by modular approach methods
Module is a set of code that has been assign a name , just as a variable. These variable name used to
refrence tha data and excute the set of codes
Fuctions
- A set of codes have written together to perfume a specific task
- In C language main progarmme is also called as fuction
- The programmer can write different sub – fuction under the main fuction
Steps to create a function in C language
a. Function ( a set of codes ) should be declared
b. Call the function
c. Function details ( the cods which we won’t write )
Fuction should be de calred by the name
Void( means empty)
Void add();
Int add();
What si nessary to use a fuction ? to reduce the progarme complexity
# include <stdion> header file
# include < conion>
Void main ()
Clrscer();
Printf( ‘ welcome”)
Getch(): ,