Session1 - Basic Programming Concepts
Session1 - Basic Programming Concepts
Session 1
Session Objectives
Discuss algorithms
Draw flowcharts
List the symbols used in flowcharts
Discuss variables
List the different data types and make use of them in your own C
programs
List and explain the different methods used for testing an algorithm
Test a program using dry run method
Understand the structure of a sample C program
Identify the types of errors that can occur
JAVA
Class Hello
{
public static void main(String args[]) Basic approach to programming
{ has remained the same inspite of
String name;
System.in.readln(name); variations in languages. The
System.out.println(“hello “ + name); three codes perform the same
}
} task.
Basic Programming Concepts / 3 of 23
The Programming Approach to
Solving Problems Classroom
Go to the
basement
BEGIN
DISPLAY ‘Hello World !’
END
START
STOP
Computational Steps
Input/Output Instructions
Decision making
& Branching
Connectors
Flow Line
Basic Programming Concepts / 8 of 23
Variables
Memory
Data15 15
Data in memory
To refer to the value in the memory space, we need to only use the variable
name. Basic Programming Concepts / 10 of 23
Guidelines to be followed while
Naming Variables
Variable names should begin with an alphabet
For example, the data type int would precede the name varName
Datatype variableName
int varName
int
float char
double boolean
unsigned int
unsigned int (Permits only
positive numbers)
short int
short int (Occupies less
memory place
space than int)
long/longdouble
long int/double (Occupies more
space than
int/double)
Basic Programming Concepts / 14 of 23
Testing the Algorithm
The three types of testing are
The values of variables are noted down in the table at every stage
The final result is displayed at the end of the execution of the
code
Basic Programming Concepts / 16 of 23
An Example of Dry Run
Step 1. Start
Step 2. X = 10 X Y M
Step 3. Y = 5 Initial values 10 5 0
Step 4. M = 0 After Step 5 10 5 65
Step 5. M = X+Y+(X*Y) After step 6 10 9 65
Step 6. Y = Y+4 After step 7 10 9 74
Step 7. M = M+Y
Step 8. Display X,Y,M
Step 9. End
Basic Programming Concepts / 17 of 23
Independent Inspection
Algorithm is given to
Person 2
Peers
Logical errors
Syntax errors
Object Code
Source Code COMPILER O/S
Source Code
Compiler converts source code into object code, that is understood and
executed by O/S.
INTERPRETER O/S
Source Code