You are on page 1of 29

FUNDAMENTALS OF

PROGRAMMING
What are Programming Languages?
• It allows us to give instructions to a computer in a language the computer
understands. Just as many human-based languages exist, there are an
array of computer programming languages that programmers can use to
communicate with a computer. 
• The portion of the language that a computer can understand is called a
“binary.” Translating programming language into binary is known as
“compiling.”

Source: https://www.codecademy.com/resources/blog/programming-languages/
Programming Paradigm
• Is a methodology or way of programming that a programming language
supports. 
• Can also be termed as method to solve some problem or do some task.
Programming paradigm is an approach to solve problem using some
programming language or also we can say it is a method to solve a
problem using tools and techniques that are available to us following some
approach.
Common Paradigms cont…
• Declarative language will focus more on specifying what a language is
supposed to accomplish rather than by what means it is supposed to
accomplish it. Such a paradigm might be used to avoid undesired side-effects
resulting from having to write one's own code. Use sets of library to do the
job.
• Functional programming is a subset of declarative programming that tries to
express problems in terms of mathematical equations and functions. It goes
out of its way to avoid the concepts of states and mutable variables which are
common in imperative languages.
• Generic programming focuses on writing skeleton algorithms in terms of
types that will be specified when the algorithm is actually used, thus allowing
some leniency to programmers who wish to avoid strict strong typing rules. It
can be a very powerful paradigm if well-implemented. It is like a Templates
that
Source:  allows the programmer to write one code for all data types.
http://www.cplusplus.com/info/description/
Common Paradigms cont…
• Imperative languages allow programmers to give the computer ordered lists of instructions
without necessarily having to explicitly state the task. It can be thought of being the opposite
of declarative programming. Telling the program how to solve something.
• Structured programming languages aim to provide some form of noteworthy structure to a
language, such as intuitive control over the order in which statements are executed (if X then
do Y otherwise do Z, do X while Y is Z). Such languages generally deprecate "jumps", such
as those provided by the goto statement in C and C++.
• Although it is sometimes used as a synonym for imperative programming, a procedural
programming language can also refer to an imperative structured programming language
which supports the concept of procedures and subroutines (also known as functions in C or
C++).
• Object-Oriented programming (sometimes abbreviated to OOP) is a subset of structured
programming which expresses programs in the terms of "objects", which are meant to model
objects in the real world. Such a paradigm allows code to be reused in remarkable ways and
is meant to be easy to understand.
Source: http://www.cplusplus.com/info/description/
Programming Languages
• Python is a versatile, general-purpose programming language. It can be
used in a variety of fields from data science and machine learning to web
development and is a great first language to learn.
• Another language that’s great when you’re starting out, Java can be used for
many things, including mobile applications, software development, and large
systems development. AP Computer Science is currently taught in Java.
• C#, Microsoft’s popular programming language, can be used for a wide
variety of applications, including game development, enterprise software,
video games, mobile apps, and more.
• C++ is one of the most powerful programming languages and is used in a
wide range of industries, including VR, software and game development,
robotics, and scientific computing.
Source: https://www.codecademy.com/resources/blog/programming-languages/
What is C++?
• Is a general purpose, object-oriented, middle-level programming
language and is an extension of C language, which makes it
possible to code C++ in a “C style”. In some situations, coding
can be done in either format, making C++ an example of a
hybrid language.
History of C++
• C++ was developed by Dr. Bjarne Stroustrup (buh·jaar·nay strau·struhp) between
1983-1985 while working at AT&T Bell Labs in New Jersey. He added features to
the original C language to produce what he called “C with classes”. These
classes define programming objects with specific features that transform the
procedural nature of C into the object-oriented programming language of C++.
• The C programming language was so named as it succeeded an earlier
programming language named “B” that had been introduced around 1970. The
name “C++” displays some programmers’ humor because the programming ++
increment operator denotes that C++ is an extension of the C language.
• C++, like C, is not platform-dependent, so programs can be created on any
operating system. Most illustrations depict output on the Windows operating
system purely because it is the most widely used desktop platform. The examples
can also be created on other platforms such as Linux or macOS.
Source: C++ Programming in Easy Steps Fifth Edition Mike
McGrath
Why Learn C++ Programming?
• It is favored by many professional programmers because it allows them to
create fast, compact programs that are robust and portable.
• Using a modern C++ Integrated Development Environment (IDE), such as
Microsoft’s Visual Studio Community Edition, the programmer can quickly
create complex applications. But to use these tools to greatest effect, the
programmer must first learn quite a bit about the C++ language itself.

Source: C++ Programming in Easy Steps Fifth Edition Mike


McGrath
Standardization of C++
• As the C++ programming language gained in popularity, it was adopted by many
programmers around the world as their programming language of choice. Some of these
programmers began to add their own extensions to the language, so it became
necessary to agree upon a precise version of C++ that could be commonly shared
internationally by all programmers.
• A standard version of C++ was defined by a joint committee of the
• American National Standards Institute (ANSI)
• International Organization for Standardization (ISO)
• This version is sometimes known as ANSI C++, and is portable to any platform and to any
development environment.
• Example programs run in a console window, such as the Command Prompt window on
Windows systems or a shell terminal window on Linux systems, to demonstrate the
mechanics of the C++ language itself. An example in the final chapter illustrates how
code generated automatically by a visual development tool on the Windows platform can,
once you’re familiar with the C++ language, be edited to create a graphical, windowed
application.
Source: C++ Programming in Easy Steps Fifth Edition Mike
McGrath
ANSI and ISO
• The International Organization for Standardization (ISO) is an international
nongovernmental organization made up of national standards bodies; it
develops and publishes a wide range of proprietary, industrial, and
commercial standards and is comprised of representatives from various
national standards organizations.
• The American National Standards Institute (ANSI) oversees the creation
and dissemination of various standards and measures, including business
norms and standards in the United States.

Source:
https://www.investopedia.com/
The Features of C++ as a Language
1. Is an open ISO-standardized language. It was is standardized by a committee of the ISO
since 1998.
2. Is a compiled language. C++ compiles directly to a machine's native code, allowing it to
be one of the fastest languages in the world, if optimized.
3. Is a strongly-typed unsafe language. C++ is a language that expects the programmer to
know what he or she is doing, but allows for incredible amounts of control as a result.
4. Supports both manifest and inferred typing. C++ supports both clear and complete
typing, allowing flexibility and a means of avoid using more words where it desired.
5. Supports both static and dynamic type checking. C++ allows type conversions to be
checked either at compile-time or at run-time, again offering another degree of
flexibility. Most C++ type checking is, however, static or errors that are independent of
the specific value.

Source: http://www.cplusplus.com/info/description/
The Features of C++ as a Language
cont…
6. Offers many paradigm choices. C++ offers remarkable support for procedural,
generic, and object-oriented programming paradigms, with many other
paradigms being possible as well.
7. Is portable. As one of the most frequently used languages in the world and as an
open language, C++ has a wide range of compilers that run on many different
platforms that support it. Code that exclusively uses C++'s standard library will
run on many platforms with few to no changes.
8. Is upwards compatible with C. being a language that directly builds off C, is
compatible with almost all C code. C++ can use C libraries with few to no
modifications of the libraries' code.
9. Has incredible library support. A search for "library" on the popular project-
management website SourceForge will yield over 3000 results for C++ libraries.
Source:
http://www.cplusplus.com/info/description/
What is an Algorithm?
• In computer programming terms, an algorithm is a set of well-defined
instructions to solve a particular problem. It takes a set of input and
produces a desired output.

An algorithm to add two numbers:


• Take two number inputs
• Add numbers using the + operator
• Display the result

Source:
https://www.programiz.com/dsa/algorithm
Characteristics of Algorithms
• Clear and Unambiguous: 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.
• Well-Defined Outputs: The algorithm must clearly define what output will be yielded and
it should be well-defined as well.
• Finite-ness: The algorithm must be finite, i.e. it should not end up in an infinite loops or
similar.
• Feasible: The algorithm must be simple, generic and practical, such that it can be
executed upon will 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 same, as expected.
Advantages of Algorithms
• It is easy to understand.
• 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.
• Branching and Looping statements are difficult to show in Algorithms
How to Design an Algorithm?
1.The problem that is to be solved by this algorithm.
2.The constraints of the problem that must be considered while solving the
problem.
3.The input to be taken to solve the problem.
4.The output to be expected when the problem the is solved.
5.The solution to this problem, in the given constraints.
Qualities of Good Algorithms
• Input and output should be defined precisely.
• Each step in the algorithm should be clear and unambiguous.
• Algorithms should be most effective among many different ways to solve a
problem.
• An algorithm shouldn't include computer code. Instead, the algorithm
should be written in such a way that it can be used in different
programming languages.

Source:
https://www.programiz.com/dsa/algorithm
Another example of an algorithm
The instructions for changing a flat tire are straightforward and go something
like the following:
1. Raise the car.
2. Remove the lug nuts that affix the faulty tire to the car.
3. Remove the tire.
4. Mount the new tire.
5. Install the lug nuts.
6. Lower the car.

Source:
https://www.programiz.com/dsa/algorithm
Algorithm of linear search
1. Start from the leftmost element of arr[] and one by one
compare x with each element of arr[].
2. If x matches with an element, return the index.
3. If x doesn’t match with any of elements, return -1.
Difference between Algorithm and
Flowchart

Source: https://www.geeksforgeeks.org/difference-between-algorithm-and-flowchart/
What is a 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”.

Source: https://www.geeksforgeeks.org/difference-between-algorithm-and-flowchart/
Brief history of flowchart
• Flowcharts to document business processes came into use in the 1920s and ‘30s.
• In 1921, Frank and Lillian Gilbreth introduced the “Flow Process Chart” to the American Society of Mechanical
Engineers (ASME).  
• In the early 1930s, Allan H. Morgensen used Gilbreth’s tools to present conferences on making work more
efficient to business people at his company.  
• In the 1940s, Art Spinanger and Ben S. Graham, spread the methods more widely. Spinanger introduced the
work simplification methods to Procter and Gamble. Graham, a director at Standard Register Industrial,
adapted flow process charts to information processing.
• In 1947, ASME adopted a symbol system for Flow Process Charts, derived from the Gilbreths’ original work.
• In the late ‘40s, Herman Goldstine and John Van Neumann used flowcharts to develop computer programs,
and diagramming soon became increasingly popular for computer programs and algorithms of all kinds.
• Flowcharts are still used for programming today, although pseudocode, a combination of words and coding
language meant for human reading, is often used to depict deeper levels of detail and get closer to a  final
product.
• In Japan, Kaoru Ishikawa (1915-1989), a key figure in quality initiatives in manufacturing, named flowcharts as
one of the key tools of quality control, along with complementary tools such as the Histogram, Check Sheet
and Cause-and-Effect Diagram, now often called the Ishikawa Diagram.
Types of flowcharts
• Document Flowcharts: These “have the purpose of showing existing
controls over document-flow through the components of a system. … The
chart is read from left to right and documents the flow of documents through
the various business units.”
• Data Flowcharts: These show “the controls governing data flows in a
system. … Data flowcharts are used primarily to show the channels that
data is transmitted through the system rather than how controls flow.”
• System Flowcharts: These “show the flow of data to and through the
major components of a system such as data entry, programs, storage
media, processors, and communication networks.”
• Program Flowcharts: These show “the controls placed internally to a
program within a system.
Source: https://www.lucidchart.com/pages/what-is-a-flowchart-tutorial#section_6
Flowchart symbols

Source: https://www.lucidchart.com/pages/what-is-a-flowchart-tutorial#section_6
Flowchart symbols

Source: https://www.lucidchart.com/pages/what-is-a-flowchart-tutorial#section_6
Flowchart symbols

Source: https://www.lucidchart.com/pages/what-is-a-flowchart-tutorial#section_6
How to plan and draw a basic flowchart
1.Define your purpose and scope. What do you hope to accomplish? Are you
studying the right things with appropriate start and end points to accomplish that
purpose? Be detailed enough in your research but simple enough in your charting
to communicate with your intended audience.
2.Identify the tasks in chronological order. This might involve talking to
participants, observing a process and/or reviewing any existing documentation. You
might write out the steps in note form, or begin a rough chart.
3.Organize them by type and corresponding shape, such as process, decision,
data, inputs or outputs.
4.Draw your chart, either sketching by hand or using a program such as Lucidchart.
5.Confirm your flowchart, walking through the steps with people who participate in
the process. Observe the process to make sure you haven’t missed anything
important to your purpose.
Source: https://www.lucidchart.com/pages/what-is-a-flowchart-tutorial#section_6

You might also like