Problem Solving Using C (Unit 1)
Problem Solving Using C (Unit 1)
Problem solving is the act of defining a problem; determining the cause of the problem;
identifying, prioritizing, and selecting alternatives for a solution; and implementing a solution.
Algorithm:
The word Algorithm means “a process or set of rules to be followed in calculations or other
problem-solving operations”. Therefore, Algorithm refers to a set of rules/instructions that step-
by-step define how a work is to be executed upon in order to get the expected results.
In programming, algorithm is a set of well-defined instructions in sequence to solve the
problem.
Step 1: Start
Step 2: Declare variables num1, num2 and sum.
Step 3: Read values num1 and num2.
Step 4: Add num1 and num2 and assign the result to sum. sum←num1+num2
Step 5: Display sum
Step 6: Stop
Write an algorithm to find the largest among three different numbers entered by user.
Step 1: Start
Step 2: Declare variables a, b and c.
Step 3: Read variables a, b and c.
Step 4: If a>b If a>c Display a is the largest number. Else Display c is the largest number. Else If
b>c Display b is the largest number. Else Display c is the greatest number.
Step 5: Stop
Flowchart – A flowchart is a graphical or pictorial representation of an algorithm. Programmers
often use it as a program-planning tool to solve a problem. It makes use of symbols which are
connected among them to indicate the flow of information and processing.
Flowcharts are used in analyzing, designing, documenting or managing a process or program in
various fields. The Flowchart is an excellent way of communicating the logic of a program. It is
easy and efficient to analyze problem using flowchart.
Symbol of Flowchart- Flowcharts use special shapes to represent different types of actions or
steps in a process. Lines and arrows show the sequence of the steps, and the relationships
among them. These are known as flowchart symbols.
C is the widely used language. It provides many features that are given below.
1. Simple
2. Machine Independent or Portable
3. Mid-level programming language
4. structured programming language
5. Rich Library
6. Memory Management
7. Fast Speed
8. Pointers
9. Recursion
10. Extensible
Structure of C Program:
Compiling C Program, Link and Run C Program:
C Character set:
Tokens: Keywords, Identifiers, and Constants:
Variables and Data types:
Standard Input/Output:
Operators and expressions: