100% found this document useful (1 vote)
69 views5 pages

Programming Techniques and Logic Introductions

The document discusses programming techniques and logic introductions. It defines problem solving as a process requiring careful planning, logical thinking, testing, and attention. It can be challenging but also exciting and satisfying. A computer solution is a set of instructions expressed in a programming language called a program. It provides examples of pseudocode to find the sum of two numbers, add three numbers and divide the total by 3. It discusses components of a program like comments, name, delimiters, sentences, and keywords. It also covers different data types like constants, variables, operators, and conditionals. Pseudocode examples are provided for different programming concepts like formulas, declaring variables, if/else conditions, loops, and while loops.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
100% found this document useful (1 vote)
69 views5 pages

Programming Techniques and Logic Introductions

The document discusses programming techniques and logic introductions. It defines problem solving as a process requiring careful planning, logical thinking, testing, and attention. It can be challenging but also exciting and satisfying. A computer solution is a set of instructions expressed in a programming language called a program. It provides examples of pseudocode to find the sum of two numbers, add three numbers and divide the total by 3. It discusses components of a program like comments, name, delimiters, sentences, and keywords. It also covers different data types like constants, variables, operators, and conditionals. Pseudocode examples are provided for different programming concepts like formulas, declaring variables, if/else conditions, loops, and while loops.
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 5

Programming Techniques and Logic Introductions

“There is no such thing as a problem without a gift for you in hand, you a seek problem because you need their gift”, If computer
problem solving can be demand in one word program, problem solving is a process requiring much though Careful, Planning,
Logical, Testing & Attention at the same time it can we challenging exciting and satisfying, experience the considerable room for
personal creativity.

The computer solution it is a set of instructions express in a programming language, a set of instructions is called program and
therefore correspond a solution to a problem.

Let’s consider the following situation.

Given 2 numbers and find their sum.

1. You can find out two numbers.


2. Add the above.
3. You will get the answer.

Steps

 Gathering the relevant information [Input] Processing the information [Processing]  Arriving at the result [Output]
 Find 3 numbers  Add above numbers  get the answer  divide by 3

Pseudo code
A setup instruction to solve the problem is team as an Algorithm. Algorithm can be
express in different ways as follows;

The problem solving written in simple English which is called Pseudo code

Components of the program and Pseudo code


1. Comment entry – An entry following the symbols //, indicate the comment entry and used to specify the comment.
2. Program Name – indicate name of the program.
3. Delimiters – {and} indicate beginning and end mark of the program, it is also requested for statement blocks.
4. Sentence – Each line of the program is a sentence.
5. Sentence Terminator – Each sentence is to be terminated with a; (Semi Colon).
6. Keywords – Normally we can use the keywords.
a. Accept – Input the data
b. Display – Normally this word used output of the program

Main task of a program is to deal with the data.

 Constant
 Variable

Constant
Constant are data elements whose value cannot change during
program execution.

Ex – 22/7

Ex – 1 Write the pseudocode to display your name.

Variable
Variables are data elements whose value change during the program execution, their two types as follows;

1. Alphanumeric
1
2. Numeric

Alphanumeric (Character) (Char)


Ex – Alphabets (A – Z, a – z) Numeric (0 – 9), Alphanumeric is mean alphabet character and numbers.

Numeric (Integer)
Numeric variables are of two types as follows;
1. Integer
2. Float
Integer – Whole numbers (+ or -) its mention as Int
Float – Number with decimal places. Ex – xx.xxx

Declaring Variables
Each variable used in program must be declared, There are two way of variable declaration available. Special Characters are not
to initialize to variable.

[Data Type] [Name of Variable]

Name of Variables Data Type

Name of Variables Data Types


1. Quantity Float; // number With Decimals Places.
2. Salary Float; // Number With Decimals Places.
3. Name Char; // Only Text.

Operators
Programs are required to perform a lot more than just simple input and output operation, these tools are known as operators.

Arithmetic Operators
 Addition (+)
 Subtraction ( – )
 Multiplication (*)
 Division (/)
 Module (%) ex – 5 + 4 = 9 [ 4&5 Operation] [+ is operator]

Relational Operators
Operator Description
 == Equal to
 > Grater than
 < Less than
 != Not Equal to
 >= Grater than or Equal to
 <= Less than or
Equal to

Logical Operators
1. Yes / No
2. True / False
3. On / Off
4. 1 / 0

2
Write the pseudocode for the following formula D = V * T you are requested to find out the Distance. In the above problem we
are concept the following factors, D = Distance, V = Velocity, T = Time.

Find the Velocity, Write the pseudocode V = U + FT, You can Find Out V

Some Example of Declaring Variables


1. Write the Pseudocode to given output. Program name is Display.
2. The following code is supposed to accept the name and the age of a person and display the same.
Identify the errors in the code and write the correct code.
3. Find the output of the following program.
4. Write the Pseudocode to Accept the Item Name, Prize, Qty, and calculate the
Total. Total = (Prize X Qty)
5. Write the Pseudocode to Accept Three Marks and Find out their Total, Average
and Display all of them.

Condition
IF Condition
If a certain condition is true you direct the program to take one cause of affection is the condition is
false, you direct the program to do something else.

Syntax of Single IF Condition


1. Write the Pseudocode accept the Marks and IF Marks Greater than or Equal to more than 50
Then the Display Should be PASS otherwise Display Should be Fail.
2. Write the Pseudocode to accept the weight and if weight greater than 60 the message should be
Fat otherwise message should me Slim.
3. Write the Pseudocode to accept a number and to find the weather that number is divided by5 or
not. If number can be divided by 5 then message should display Can Divide otherwise message should display
Cannot Divide.
4. Write Pseudocode to accept number weather you have checked odd or even number.
5. Write the Pseudocode to accept Age of two Different Persons weather they are same age or not.
6. Write the Pseudocode to accept a number and find the number is Negative or Positive.
7. Write the Pseudocode and Find the Distance. (Time = 60, Speed = 12,) D = T * S.

Nested IF Condition
Nested IF means, we use multiple IF Condition in one form, it has syntax as follows;
we use second if condition at the else statement of the First IF Condition.

1. Write the Pseudocode to accept 4 Marks of a Student and find the Total,
Average, and Grade and display the Total, Average and Grade using given
information.
2. Find out the Output of the following program. 

Loop
One of the most important characteristics of a computer is its ability to execute a service of
instruction repeat. This cycle introduced the conceppt of Loop which allow the user grade flexibility in controlling the
number of time a specific task is to be repeater

Note1: A Signal of code that is executed repeat is called Loop.


Note2: The Loop concept is essential to good problem solve in technique.

3
While Loop
While Loop is a method, when the user use this Loop, there are user wish to use syntax, the syntax as follows;

In the following program we use the While Loop simply to give variety of outputs. Ex – 5 Then

Sum Number Counter 5


5 5 1
4
7 2 2
While (Counter =>-4)
8 1 3 3
12 4 4 {
18 6 5 2
20 2 6 Display Counter
30 10 7 1
42 12 8 } Counter == Counter -2
End Loop
47 5 9
50 3 10

1. Write the Pseudocode to input any 5 numbers and find their Accept (n) Number and Find (n) Number Sum
Sum? {
2. Write the Pseudocode to accept (n) number and Display Number == 0, Counter == 10, Sum ==0 Int;
reserve. Display “Please Enter (n) Positive Number”;
3. Write the Pseudocode to Adding 50 Numbers and display Sum. Accept Counter;
While (Counter => 0)
4. Write the Pseudocode to accept Positive (n) number and find
{
their Sum of (n) numbers.  Accept Number While(Counter =<10)
5. Write the Pseudocode to Display the following  {
Sum = Number + Sum;
This is Line Counter==Counter+1;
6. Write the Pseudocode to Given Output  4 1 Counter == Counter-1 Display “This..1”
7. Write the Pseudocode to accept 10 numbers 2 This is Line } Counter;
and Find their average and display that. 0 2 Display Sum; }
-2 This is Line }
While Statement -4 3
{
While Statement
While Statement
Counter, Number, Sum int;
{
{
Sum == 0;
Number int;
Number int;
Counter ==1;
Number == 10;
Number == 0;
While (Counter=<10)
Accept Number;
While (Number=>10)
{
While (Number=<0)
x` {
Accept Number;
{
Number == (Number +1)
Counter == Counter +1;
Number == (Number -1)
Display Number
Sum == Sum + Number;
Display Number
}}
Display Sum
}}
}}

4
5

You might also like