Written by students who passed Immediately available after payment Read online or as PDF Wrong document? Swap it for free 4.6 TrustPilot
logo-home
Class notes

C/C++ Programming Basics

Rating
-
Sold
-
Pages
92
Uploaded on
20-11-2023
Written in
2023/2024

This document is intended to give in-depth overview of basics of C programming language. The topics included within will help to learn basics about C programming language from scratch.

Institution
Course

Content preview

UNIT-1
Algoritham
What is an Algorithm?
➢ The word Algorithm means ” A set of finite rules or instructions to be followed in
calculations or other problem-solving operations ”
➢ Or
➢ ” A procedure for solving a mathematical problem in a finite number of steps that
frequently involves recursive operations”.

➢ Therefore Algorithm refers to a sequence of finite steps to solve a particular problem.


➢ That can be understood by taking the example of cooking a new recipe. To cook a
new recipe, one reads the instructions and steps and executes them one by one, in the
given sequence. The result thus obtained is the new dish cooked perfectly.
➢ The Algorithm designed are language-independent, i.e. they are just plain instructions
that can be implemented in any language, and yet the output will be the same, as
expected.

Characteristics of an Algorithm




Algoritham must have the following characteristics:



1|Page

, ➢ Clear and Unambiguous: The algorithm should be clear and unambiguous. Each of
its steps should be clear in all aspects and must lead to only one meaning.
➢ Well-Defined Inputs: If an algorithm says to take inputs, it should be well-defined
inputs. It may or may not take input.

➢ Well-Defined Outputs: The algorithm must clearly define what output will be
yielded and it should be well-defined as well. It should take at least 1 output.

➢ Finite-ness: The algorithm must be finite, i.e. it should terminate after a finite time.

➢ Feasible: The algorithm must be simple, generic, and practical, such that it can be
executed with the available resources. It must not contain some future technology or
anything.

➢ Language Independent: The Algorithm designed must be language-independent, i.e.
it must be just plain instructions that can be implemented in any language, and yet the
output will be the same, as expected.

Properties of Algorithm:
➢ It should terminate after a finite time.
➢ It should produce at least one output.
➢ It should take zero or more input.
➢ It should be deterministic means giving the same output for the same input case.
➢ Every step in the algorithm must be effective i.e. every step should do some work.


Advantages of Algorithms:
➢ It is easy to understand.
➢ An algorithm is a step-wise representation of a solution to a given problem.
➢ In Algorithm the problem is broken down into smaller pieces or steps hence, it is
easier for the programmer to convert it into an actual program.


Disadvantages of Algorithms:
➢ Writing an algorithm takes a long time so it is time-consuming.
➢ Understanding complex logic through algorithms can be very difficult.
➢ Branching and Looping statements are difficult to show in Algorithms(imp).


How to Design an Algorithm?
In order to write an algorithm, the following things are needed as a pre-requisite:
➢ The problem that is to be solved by this algorithm i.e. clear problem definition.
➢ The constraints of the problem must be considered while solving the problem.

2|Page

, ➢ The input to be taken to solve the problem.
➢ The output to be expected when the problem is solved.
➢ The solution to this problem, is within the given constraints.
➢ Then the algorithm is written with the help of the above parameters such that it solves
the problem.



Pseudo code
➢ Pseudo code is a combination of two words: Pseudo and Code. 'Pseudo' means
imitation and 'code' refer to instruction written in the programming language.
➢ Pseudo code is not a real programming code. It is the generic way of describing an
algorithm without using any specific programming language-related
➢ The pseudo code cannot be compiled. It cannot be executed and there are no real
formatting or syntax rules for writing pseudo codes.
➢ It is simply an important step in producing the final code.



Advantages of Pseudo code:
➢ Since, it is language independent, it can be used by most programmers.
➢ It helps to design in plain natural language.
➢ It is easier to develop the program from pseudo code than with a flowchart.
➢ It is easy to translate to the programming language.
➢ Its simple structure and readability makes it easier to modify as well.


Disadvantages of Pseudo code:
➢ It does not provide the visual representation of the program logic.
➢ There are no accepted standards for writing pseudo code.




Flowchart
What is a Flowchart?
➢ Flowchart is a graphical 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.
➢ The process of drawing a flowchart for an algorithm is known as “flowcharting”.


3|Page

, FLOWCHART SYMBOLS
Name Symbol Purpose
Terminal / The terminator shows where your process begins
Terminator or ends. You can use words like ‘Start’, ‘Begin’,
‘End’ inside the terminator shape to make things
more obvious.


Process / Flowchart process shape is used to represent a
Rectangle process, action step, or operation. While these are
pictured with rectangles. Eg. Aaddition.
Subtraction. Etc



Data (I/O) Denotes Input/Output Operations. This takes the
shape of a parallelogram.




Decision The decision shape is represented as a Diamond. It
is used for decision making. This shape is quite
unique with two arrows coming out of it. One from
the bottom point corresponding to Yes or True and
one from either the right/left point corresponding
to No or False. The arrows should always be
labeled to avoid confusion in the process flow.
Document The document object is a rectangle with a wave-
like base. This shape is used to represent a
Document or Report in a process flow.




Subroutine / Its called a subroutine if you use this object in
Predefined flowcharting a software program. This allows you
Process to write one subroutine/function and call it as often
as you like from anywhere in the code.
The same object is also called a Predefined
Process. This means the flowchart for the
predefined process has to be already drawn, and
you should reference the flowchart for more
information.


←↑→↓
Flow Lines Denotes the direction of logic flow in the program




4|Page

Written for

Institution
Course
Unknown

Document information

Uploaded on
November 20, 2023
Number of pages
92
Written in
2023/2024
Type
Class notes
Professor(s)
A. zubair
Contains
All classes

Subjects

$8.69
Get access to the full document:

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Get to know the seller
Seller avatar
riyonabiz7

Get to know the seller

Seller avatar
riyonabiz7 CMR Engineering College
Follow You need to be logged in order to follow users or courses
Sold
-
Member since
2 year
Number of followers
0
Documents
1
Last sold
-

0.0

0 reviews

5
0
4
0
3
0
2
0
1
0

Recently viewed by you

Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions