0% found this document useful (0 votes)
17 views

Prog Assignment (Ai)

Uploaded by

izaanfojisiddiqi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

Prog Assignment (Ai)

Uploaded by

izaanfojisiddiqi
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

The Government Sadiq College Women

University Bahawalpur, Pakistan

Assignment 1
Programming Fundamentals

_____________________________________________

_____________________________________________

Submitted by: Submitted to:


Qurrat ul Ain Ms. Arfa Maham
Siddiqi

October 31, 2024

Registration no: 2413002594


Understanding Algorithms and Flowcharts

Definition:
An algorithm is a step-by-step process or set of rules for solving a particular problem or
completing a specific task. In programming and computer science, an algorithm is a logical
sequence of actions that are used to accomplish a goal, like sorting a list, finding the shortest path,
or calculating the average of a set of numbers.

Key Components of Flowcharts:


1. Oval (Start/End) - Indicates the starting or ending point of the process.
2. Rectangle (Process) - Shows an action or operation, such as calculations.
3. Diamond (Decision) - Represents a decision point, typically a yes/no or true/false
question.
4. Arrow - Shows the direction of flow from one step to the next.
5. Parallelogram (Input/Output) - Denotes input to and output from a process.

Why Algorithms and Flowcharts are Important?

 Problem Solving: Algorithms provide a structured approach to problem-solving,


ensuring that each step is clearly defined.
 Efficiency: Writing out an algorithm helps you identify the most efficient way to
complete a task.
 Communication: Flowcharts make it easier to explain processes to others because they
visually break down each step, which is especially useful when collaborating on
projects.

Difference between both:


Examples:

 Algorithm:
1. Start.
2. Input a number i assigning a value (example: 0).
3. Compare i with a value given by user (let it be 5).
o If i<5, then it will print “*” and hence the process will be forwarded to next step.
o Otherwise, the program ends.
4. Output will be “*”.
5. End.
(It is noted that the given flowchart is according to c language and it’s a loop. The
program won’t end unless i becomes greater than 5).

Flowchart:

Calculate the Sum of the First 50 Numbers:


 Algorithm:
1. Declare number N= 0 and sum= 0.
2. Determine N by N= N+1.
3. Calculate the sum by the formula: Sum= N + Sum.
4. Add a loop between steps 2 and 3 until N= 50.
5. Print Sum.
6. End.

You might also like