1
PROBLEM SOLVING AND PROGRAMMING
Problem Solving Aspects
Problem definition phase – Understanding of the problem, Preliminary
investigation, “what must be done” rather than “how to do it”.
Problem solving phases – Different ways to solve the problem, Difficulty
to find out fruitful path
Use of specific examples – Pick a specific example of a general problem,
Find our mechanism behind it.
Similarities among problems – Use past knowledge to solve current
problem
Working backwards from the solution – Backtrack to starting point
(objective).
Main aspects of problem-solving:
1. Problem Identification
Understand and define the problem clearly.
Ask: What exactly is wrong? What are the symptoms?
2. Understanding the Problem
Gather relevant information and analyze the context.
Identify constraints, requirements, and stakeholders involved.
3. Breaking Down the Problem
Divide the problem into smaller, manageable parts (decomposition).
Helps in reducing complexity and tackling one part at a time.
4. Generating Possible Solutions
Brainstorm multiple solutions or strategies.
Think creatively and consider alternative approaches.
5. Evaluating and Selecting the Best Solution
Compare solutions based on criteria like:
o Feasibility
o Cost
o Time
o Risks
o Effectiveness
6. Planning the Solution
Develop a step-by-step action plan.
Allocate resources, set deadlines, and define responsibilities.
2
7. Implementing the Solution
Execute the plan systematically.
Stay adaptive in case adjustments are needed during execution.
8. Monitoring and Reviewing
Track progress and assess the effectiveness of the solution.
Use feedback to improve or modify the solution if necessary.
9. Reflecting and Learning
After solving the problem, analyze:
o What worked well?
o What didn’t?
o What can be learned for future problems?
Steps Involved in Problem Solving
A computer cannot solve a problem on its own. One has to provide step by
step solutions of the problem to the computer. In fact, the task of problem solving
is not that of the computer. It is the programmer who has to write down the
solution to the problem in terms of simple operations which the computer can
understand and execute.
In order to solve a problem by the computer,
one has to pass though certain stages or steps.
They are
1. Understanding the problem
2. Analyzing the problem
3. Developing the solution
4. Coding and implementation.
1. Understanding the problem: Here we try to understand the problem to be
solved in totally. Before with the next stage or step, we should be absolutely sure
about the objectives of the given problem.
2. Analyzing the problem: After understanding thoroughly the problem to be
solved, we look different ways of solving the problem and evaluate each of these
methods. The idea here is to search an appropriate solution to the problem under
consideration. The end result of this stage is a broad overview of the sequence of
operations that are to be carries out to solve the given problem.
3
3. Developing the solution: Here the overview of the sequence of operations that
was the result of analysis stage is expanded to form a detailed step by step solution
to the problem under consideration.
4. Coding and implementation: The last stage of the problem solving is the
conversion of the detailed sequence of operations in to a language that the
computer can understand. Here each step is converted to its equivalent instruction
or instructions in the computer language that has been chosen for the implantation.
Problem Identification
Problem identification is the very first step in the programming problem-
solving process. It involves recognizing that there is a problem to be solved and
clearly defining what that problem is.
Why Problem Identification is Important?
Prevents wasting time on solving the wrong problem.
Helps in choosing the correct tools, logic, and data structures.
Sets the foundation for writing accurate, efficient code.
Improves focus and direction in problem-solving.
Key Aspects of Problem Identification in Programming
1. Recognize the Need
o Why is a solution required?
o What is the issue or goal?
2. Define the Problem Clearly
o Describe the problem in one or two precise sentences.
o Avoid jumping into solutions too early.
3. Understand the Objective
o What should the program achieve?
o What is the expected output for given inputs?
4. Identify Stakeholders or Users
o Who needs this program?
o What are their expectations?
5. Know the Environment
o Is the program for web, mobile, embedded system, etc.?
o Are there system constraints (speed, memory, platform)?
6. Clarify Assumptions
o Example: Are inputs always valid? Is the data size fixed?
4
Problem Understanding
It is the process of:
Interpreting the requirements of the task.
Identifying inputs, expected outputs, and constraints.
Determining what kind of logic or algorithm will be needed.
Key Aspects of Problem Understanding
1. Read the Problem Statement Carefully
o Understand what needs to be done (objective).
o Look for keywords like “minimum,” “maximum,” “sort,” “search,”
“count,” etc.
2. Identify Input and Output
o What data will be provided?
o What format will the output be in?
3. Recognize Constraints
o Examples: size of input, time/memory limits, data type restrictions.
o Helps in choosing the right algorithm and data structures.
4. Understand Edge Cases
o Think about what can go wrong (e.g., empty arrays, negative
numbers).
o Consider all possible inputs.
5. Clarify Ambiguities
o If something is unclear, seek clarification (from a teacher, interviewer,
or documentation).
o Example: “Should duplicate values be considered?” or “Is the array
always sorted?”
6. Visualize with Examples
o Work through small test cases manually.
o Helps you understand the logic before implementing.
Algorithm
Definition
A set of sequential steps usually written in Ordinary Language to solve a
given problem is called Algorithm.
It may be possible to solve to problem in more than one ways, resulting in
more than one algorithm. The choice of various algorithms depends on the factors
like reliability, accuracy and easy to modify. The most important factor in the
choice of algorithm is the time requirement to execute it, after writing code in
5
High-level language with the help of a computer. The algorithm which will need
the least time when executed is considered the best.
Steps involved in algorithm development
An algorithm can be defined as “a complete, unambiguous, finite number of
logical steps for solving a specific problem“
Step 1: Identification of input: For an algorithm, there are quantities to be
supplied called input and these are fed externally. The input is to be indentified
first for any specified problem.
Step 2: Identification of output: From an algorithm, at least one quantity is
produced, called for any specified problem.
Step 3: Identification the processing operations: All the calculations to be
performed in order to lead to output from the input are to be identified in an
orderly manner.
Step 4: Processing Definiteness: The instructions composing the algorithm must
be clear and there should not be any ambiguity in them.
Step 5 : Processing Finiteness: If we go through the algorithm, then for all cases,
the algorithm should terminate after a finite number of steps.
Step 6: Possessing Effectiveness: The instructions in the algorithm must be
sufficiently basic and in practice they can be carries out easily.
Characteristics of a good algorithm
• Precision — the steps are precisely stated or defined.
• Uniqueness — results of each step are uniquely defined and only depend on
the input and the result of the preceding steps.
• Finiteness — the algorithm always stops after a finite number of steps.
• Input — the algorithm receives some input.
• Output — the algorithm produces some output.
While writing an algorithm, it is required to clearly identify the following:
• The input to be taken from the user
• Processing or computation to be performed to get the desired result
• The output desired by the user
6
Example 1
Suppose we want to find the average of three numbers, the algorithm is as follows:
Steps
Step 1 : Read the numbers a, b, c
Step 2 : Compute the sum of a, b and c
Step 3 : Divide the sum by 3
Step 4 : Store the result in variable d
Step 5 : Print the value of d
Step 6 : End of the program
Example 2
Write an algorithm to calculate the simple interest using the formula Simple
interest = P*N* R/100 where P is principle Amount, N is the number of years and
R is the rate of interest.
Steps
Step 1: Read the three input quantities P, N and R.
Step 2 : Calculate simple interest as Simple interest = P* N* R/100
Step 3: Print simple interest.
Step 4: Stop.
Example 3
Write an algorithm to find the largest of three numbers X, Y, Z.
Steps
Step 1: Read the numbers X,Y,Z.
Step 2: if (X > Y) Big = X else BIG = Y
Step 3 : if (BIG < Z)
Step 4: Big = Z
Step 5: Print the largest number i.e. Big
Step 6: Stop.
Example 4
Write down an algorithm to find the largest data value of a set of given data values.
Steps
Step 1: LARGE 0
Step 2: read NUM
Step 3: While NUM > = 0 do
3.1 if NUM > LARGE
3.1.1 then
7
3.1.1.1 LARGE NUM
3.2. read NUM
Step 4: Write “largest data value is”, LARGE
Step 5: end.
Solution Planning
Solution planning is the phase where you decide how to solve a
programming problem before writing any code.
Why Solution Planning is Important?
Saves time by preventing trial-and-error coding.
Helps choose the right logic, algorithm, and data structures.
Makes debugging and testing easier.
Improves code clarity, modularity, and maintainability.
Steps in Solution Planning
1. Restate the Problem Clearly
o Write down what you’re solving.
o Identify:
Input
Output
Constraints
Edge cases
2. Break the Problem into Sub-Problems
o Divide the task into smaller logical steps.
o Example:
Input handling
Processing
Output generation
3. Choose the Right Algorithm
o Do you need:
A loop? A condition? Recursion?
Searching or sorting?
A greedy, backtracking, or dynamic programming approach?
4. Select Appropriate Data Structures
o Arrays, lists, stacks, queues, hash tables, trees, etc.
o Pick based on access speed, insertion, and deletion needs.
5. Design Sample Test Cases
o Try with small inputs to mentally check if the logic works.
8
o Consider:
Normal case
Edge case
Invalid input case
6. Write Pseudocode or Flowcharts (Optional but Helpful)
o Helps visualize the logic before translating into code.
7. Think About Efficiency
o Time complexity (speed)
o Space complexity (memory usage)
o Can the solution be optimized?
Flowchart
Definition
A flow chart is a step by step diagrammatic representation of the logic paths
to solve a given problem. (Or)
A flowchart is visual or graphical representation of an algorithm.
The flowcharts are pictorial representation of the methods to b used to solve
a given problem and help a great deal to analyze the problem and plan its solution
in a systematic and orderly manner. A flowchart when translated in to a proper
computer language, results in a complete program.
Advantages of Flowcharts
Makes Logic Clear.
Communication.
Effective Analysis.
Useful in Coding.
Proper Testing and Debugging.
Appropriate Documentation.
Symbols used in Flow-Charts
The symbols that we make use while drawing flowcharts as given below are
as per conventions followed by International Standard Organization (ISO).
Oval: Rectangle with rounded sides is used to indicate either START/ STOP of the
program. ..
9
Input and output indicators: Parallelograms are used to represent input and
output operations. Statements like INPUT, READ and PRINT are represented in
these Parallelograms.
Process Indicators: Rectangle is used to indicate any set of processing operation
such as for storing arithmetic operations.
Decision Makers: The diamond is used for indicating the step of decision making
and therefore known as decision box. Decision boxes are used to test the
conditions or ask questions and depending upon the answers, the appropriate
actions are taken by the computer. The decision box symbol is
Flow Lines: Flow lines indicate the direction being followed in the flowchart. In a
Flowchart, every line must have an arrow on it to indicate the direction. The
arrows may be in any direction
On- Page connectors: Circles are used to join the different parts of a flowchart
and these circles are called on-page connectors. The uses of these connectors give
a neat shape to the flowcharts. Ina complicated problems, a flowchart may run in to
several pages. The parts of the flowchart on different pages are to be joined with
each other. The parts to be joined are indicated by the circle.
Off-page connectors: This connector represents a break in the path of flowchart
which is too large to fit on a single page. It is similar to on-page connector. The
10
connector symbol marks where the algorithm ends on the first page and where it
continues on the second.
Example 1
A Flowchart to display sum of two numbers
Example 2
A Flowchart to calculate square of a number
11
Example 3
A flowchart to solve the problem of a non-functioning light bulb
Example 4
A flowchart to calculate are and perimeter of a rectangle
12
Differences between Algorithm and Flowchart
Flowgorithm
Flowgorithm is a free, visual programming tool that allows you to create
programs using flowcharts instead of writing traditional code.
It's beginner-friendly and ideal for learning program logic, control
structures, and algorithms without needing to know programming syntax.
Key Features of Flowgorithm
Drag-and-drop flowchart-based programming.
Supports basic programming structures:
o Input/Output
o Variables and Assignments
o Loops (While, Do-While, For)
o If-Else Conditions
o Functions/Procedures
Can convert flowcharts to actual code in languages like C, Python, Java, etc.
Real-time syntax checking and simulation.
Steps to Use Flowgorithm
1. Download and Install:
o Website: https://flowgorithm.org
2. Create Flowchart:
o Start with the Start symbol.
13
o Add symbols for input, processing, decision-making, and output.
3. Run and Test:
o Click Run to simulate the logic.
o See how values change step-by-step.
4. Generate Code (Optional):
o Go to Tools > Source Code Viewer to generate equivalent
code (C, Python, Java, etc.)
Benefits of Using Flowgorithm
Visual Learning: Great for beginners to understand logic before learning
syntax.
Debugging Made Simple: Watch your logic flow step-by-step.
Transition to Code: Helps students move from flowcharts to actual
programming languages.
*********************
14
Overview of C Programming
History of C
C was developed in the early 1970s by Dennis Ritchie at Bell Laboratories.
To be used for UNIX operating systems.
C was initially developed for writing system software.
Many other commonly used programming languages such as C++ and Java
are also based on C.
Characteristics of C
A high level programming language and it has32 keywords.
Suits for structured programming.
Stable and Quick language.
Facilitates low level (bitwise) programming.
Uses of C
C language is primarily used for system programming.
Portability, convenience and efficiency
C is widely used to implement end-user applications.
Main Elements of C Language
1. Character Set
The basic characters used in C.
Includes:
o Letters: A–Z, a–z
o Digits: 0–9
o Special Characters: +, -, *, /, =, ;, {}, [], etc.
o White spaces: space, tab, newline
2. Keywords
Reserved words with special meaning.
Examples:
int, float, if, else, return, while, for, void, break, continue
C has 32 standard keywords.
3. Identifiers
Names used for variables, functions, arrays, etc.
Rules:
o Must begin with a letter or underscore (_)
o Cannot use keywords as names
o Case-sensitive (e.g., Sum ≠ sum)
15
4. Constants
Fixed values that don’t change during program execution.
Types:
o Integer constants: 10, -25
o Floating-point constants: 3.14, -0.001
o Character constants: 'a', '5'
o String constants: "Hello"
5. Variables
Storage locations with names.
Syntax:
int a = 10;
float pi = 3.14;
6. Data Types
Define the type of data a variable can store.
Basic types:
o int, float, char, double
Derived types:
o arrays, pointers, structures, unions
7. Operators
Symbols used to perform operations on data.
Categories:
o Arithmetic: +, -, *, /, %
o Relational: ==, !=, <, >, <=, >=
o Logical: &&, ||, !
o Assignment: =, +=, -=, etc.
o Increment/Decrement: ++, --
8. Expressions
Combination of variables, constants, and operators that produce a value.
9. Statements
Instructions for the compiler to perform specific actions.
10. Functions
Block of code that performs a specific task.
11. Control Statements
Used to control the flow of execution.
Types:
o Decision-making: if, if-else, switch
o Loops: for, while, do-while
o Jump: break, continue, goto, return
16
Basic Structure of C Program
C program is composed of preprocessor command, global declaration
sections and one or more functions.
Preprocessor directives
Special instructions that indicate how to prepare the program
for compilation
Eg: include commands tells the compiler that some information
is needed from header file to execute the program
#include<stdio.h>
All preprocessor commands start with hash symbol(#)
Global Declarations (Optional)
Variables or functions declared outside of any function.
main() Function
The starting point of every C program.
C program contains one or more functions.
The statements in a C program are written in a logical sequence
to perform a specific task.
Execution of a C program begins at the main() function.
You can choose any name for the functions. Every program
must contain one function that has its name as main().
Functions divided into 2 parts
Declarative section – describes the data used in the function
– local declarations – visible only within the function
17
Statement section – codes that manipulates the data to perform
specific task
User-Defined Functions (Optional)
Functions created by the programmer to organize code.
C Tokens
Tokens are building blocks in C language
Smallest unit of C program
Program is constructed using combination of tokens
Six main types of tokens
1) Keywords
2) Variables
3) Constants
4) Strings
5) Special Character
6) Operators
Variables
A variable is defined as a meaningful name given to the data storage location
in computer memory.
When using a variable, we actually refer to address of the memory where the
data is stored. C language supports two basic kinds of variables.
Numeric variables can be used to store either integer values or floating point
values.
While an integer value is a whole numbers without a fraction part or decimal
point, a floating point number, can have a decimal point in them.
Numeric values may also be associated with modifiers like short, long,
signed and unsigned.
By default, C automatically a numeric variable signed.
Character variables can include any letter from the alphabet or from the
ASCII chart and numbers 0 – 9 that are put between single quotes.
To declare a variable specify data type of the variable followed by its name.
Variable names should always be meaningful and must reflect the purpose of
their usage in the program.
Variable declaration always ends with a semicolon. Example,
int emp_num;
float salary;
char grade;
18
double balance_amount;
unsigned short int acc_no;
Basic Data types in C
Datatype Keyword Size in bytes Range Use
Character char 1 -128 to 127 To store characters
Integer int 2 -32768 to To store integer
32767 numbers
Floating float 4 3.4E-38 to To store floating point
point 3.4E+38 numbers
Double double 8 1.7E-308 to To store big floating
1.7E+308 point numbers
Valueless void 0 Valueless -
DATA TYPE SIZE IN BYTES RANGE
char 1 -128 to 127
unsigned char 1 0 to 255
signed char 1 -128 to 127
In C Programming Language, the character set follow ASCII (American
Standard Code for Information Interchange) code text format.
Every character in C language has the respective ASCII value which is used
to convert a character into Binary language.
For example: ASCII value of alphabet ranges
A to Z 65 to 90
a to z – 97 to 122
Note:
Sign bit - leftmost bit of the memory word
It determines the sign of the content stored in the memory
0 – positive value
1 – negative value
19
unsigned int/char : sign bit is free
Entire memory used to store non- negative value
DATA TYPE SIZE IN BYTES RANGE
int 2 -32768 to 32767
unsigned int 2 0 to 65535
signed short int 2 -32768 to 32767
signed int 2 -32768 to 32767
short int 2 -32768 to 32767
unsigned short int 2 0 to 65535
long int 4 -2147483648 to 2147483647
unsigned long int 4 0 to 4294967295
signed long int 4 -2147483648 to 2147483647
Float and double
DATA TYPE SIZE IN BYTES RANGE
float 4 3.4E-38 to 3.4E+38
double 8 1.7E-308 to 1.7E+308
long double 10 3.4E-4932 to 1.1E+4932
Operators in C
C language supports a lot of operators to be used in expressions. These
operators can be categorized into the following major groups:
Arithmetic operators
Relational Operators
Equality Operators
Logical Operators
Unary Operators
Conditional Operators
20
Bitwise Operators
Assignment operators
Comma Operator
Size of Operator
Arithmetic Operators
OPERATION OPERATOR SYNTAX COMMENT RESULT
Multiply * a * b result = a * b 27
Divide / a / b result = a / b 3
Addition + a + b result = a + b 12
Subtraction - a - b result = a – b 6
Modulus % a % b result = a % b 0
Relational Operators
Also known as a comparison operator that compares two
values.
Expressions that contain relational operators are called relational
expressions.
Relational operators return true or false value, depending on
whether the conditional relationship between the two operands holds or not.
OPERATOR MEANING EXAMPLE
< LESS THAN 3 < 5 GIVES 1
> GREATER THAN 7 > 9 GIVES 0
>= LESS THAN OR EQUAL TO 100 >= 100 GIVES 1
<= GREATER THAN EQUAL TO 50 >=100 GIVES 0
21
Equality Operators
C language supports two kinds of equality operators to compare their
operands for strict equality or inequality. They are equal to (==) and not
equal to (!=) operator.
The equality operators have lower precedence than the relational operators.
OPERATOR MEANING
== RETURNS 1 IF BOTH OPERANDS ARE EQUAL, 0
OTHERWISE
!= RETURNS 1 IF OPERANDS DO NOT HAVE THE SAME
VALUE, 0 OTHERWISE
Logical Operators
C language supports three logical operators. They are- Logical AND (&&),
Logical OR (||) and Logical NOT (!).
As in case of arithmetic expressions, the logical expressions are evaluated
from left to right.
A B A &&B A B A || B
0 0 0 0 0 0
0 1 0 0 1 1
1 0 0 1 0 1
1 1 1 1 1 1
Unary Operators
Unary operators act on single operands. C language supports three unary
operators.
They are unary minus, increment and decrement operators.
When an operand is preceded by a minus sign, the unary operator negates its
value. The increment operator is a unary operator that increases the value of
its operand by 1.
Similarly, the decrement operator decreases the value of its operand by 1.
For example,
22
int x = 10, y; whereas, y = ++x;
is equivalent to writing
x = x + 1;
y = x;
y = x++;
is equivalent to writing
y = x;
x = x + 1;
Conditional Operator
The conditional operator (?:) is just like an if .. else statement that can be
written within expressions.
The syntax of the conditional operator is exp1 ? exp2 : exp3
Here, exp1 is evaluated first. If it is true then exp2 is evaluated and becomes
the result of the expression, otherwise exp3 is evaluated and becomes the
result of the expression.
For example, large = ( a > b) ? a : b
Conditional operators make the program code more compact, more readable,
and safer to use as it is easier both to check and guarantee that the arguments
that are used for evaluation.
Conditional operator is also known as ternary operator as it is neither a unary
nor a binary operator; it takes three operands.
Bitwise Operators
Bitwise operators perform operations at bit level. These operators include:
bitwise AND, bitwise OR, bitwise XOR and shift operators.
The bitwise AND operator (&) is a small version of the boolean AND (&&)
as it performs operation on bits instead of bytes, chars, integers, etc.
The bitwise OR operator (|) is a small version of the boolean OR (||) as it
performs operation on bits instead of bytes, chars, integers, etc.
The bitwise NOT (~), or complement, is a unary operation that performs
logical negation on each bit of the operand. By performing negation of each
bit, it actually produces the ones' complement of the given binary value.
The bitwise XOR operator (^) performs operation on individual bits of the
operands. The result of XOR operation is shown in the table.
23
Assignment Operators
The assignment operator is responsible for assigning values to the variables.
While the equal sign (=) is the fundamental assignment operator, C also
supports other assignment operators that provide shorthand ways to
represent common variable assignments. They are shown in the table.
OPERATOR SYNTAX EQUIVALENT TO
/= variable /= expression variable = variable / expression
\= variable \= expression variable = variable \ expression
*= variable *= expression variable = variable * expression
+= variable += expression variable = variable + expression
-= variable -= expression variable = variable - expression
&= variable &= expression variable = variable & expression
^= variable ^= expression variable = variable ^ expression
<<= variable <<= amount variable = variable << amount
>>= variable >>= amount variable = variable >> amount
Comma Operator
The comma operator in C takes two operands. It works by evaluating the
first and discarding its value, and then evaluates the second and returns the
value as the result of the expression.
Comma separated operands when chained together are evaluated in left-to-
right sequence with the right-most value yielding the result of the
expression.
Among all the operators, the comma operator has the lowest precedence. For
example,
int a=2, b=3, x=0;
x = (++a, b+=a);
Now, the value of x = 6.
24
Sizeof Operator
• sizeof is a unary operator used to calculate the sizes of data types.
• It can be applied to all data types.
• The operator returns the size of the variable, data type or expression in bytes.
• ‘sizeof’ operator is used to determine the amount of memory space that the
variable/expression/data type will take. For example,
• sizeof(char) returns 1, that is the size of a character data type. If we have,
int a = 10;
unsigned int result;
result = sizeof(a);
then result = 2,
Operator Precedence Chart
Expressions
In C programming, an expression is a combination of variables,
constants, operators, and function calls that the compiler evaluates to
produce a value.
Definition:
An expression in C is a valid combination of operands (like variables or
constants) and operators that results in a single value.
25
Types of Expressions in C
1. Constant Expression Contains only constants 10 + 20
2. Arithmetic Expression Uses arithmetic operators a + b, x * y / z
3. Relational Expression Compares two values a > b, x == y
4. Logical Expression Combines values using logical operators a > b && x < y
5. Assignment Expression Assigns a value to a variable a = b + 5
6. Increment/Decrement Increases or decreases a value i++, --j
7. Conditional Expression (Ternary) Makes a decision a > b ? a : b
Type Conversion and Type Casting
Type conversion and type casting of variables refers to changing a variable
of one data type into another.
While type conversion is done implicitly, casting has to be done explicitly
by the programmer. We will discuss both of them here.
Type conversion is done when the expression has variables of different data
types. So to evaluate the expression, the data type is promoted from lower to
higher level where the hierarchy of data types can be given as: double, float,
long, int, short and char.
For example, type conversion is automatically done when we assign an
integer value to a floating point variable. For ex,
float x;
int y = 3;
x = y;
Now, x = 3.0,
• Type casting is also known as forced conversion. It is done when the value
of a higher data type has to be converted in to the value of a lower data type.
For example, we need to explicitly type cast an integer variable into a
floating point variable.
float salary = 10000.00;
int sal;
sal = (int) salary;
• Typecasting can be done by placing the destination data type in parentheses
followed by the variable name that has to be converted.
• Type conversion is done when the expression has variables of different data
types. To evaluate the expression, the data type is promoted from lower to
higher level where the hierarchy of data types (from higher to lower) can be
given as: double, float, long, int, short, and char.
26
Typecasting is also known as forced conversion. Type-casting an arithmetic
expression tells the compiler to represent the value of the expression in a
certain way. It is done when the value of a higher data type has to be
converted into the value of a lower data type. But this casting is under the
programmer’s control and not under compiler’s control.
2 Mark questions:
1. What are the basic steps involved in problem solving?
2. Define Algorithm.
3. Write an Algorithm for perimeter of Triangle.
4. What is Flowchart?
5. What are the symbols of Flowchart?
Long answer questions:
1. Differentiate between Algorithm and Flowchart.
2. Write an algorithm to find greatest of given three numbers.
3. Write an algorithm to check whether given integer value is PRIME or NOT.
********************