0% found this document useful (0 votes)
7 views20 pages

Unit 1

The document discusses computational thinking and its key concepts including decomposition, abstraction, pattern recognition, and algorithms. It also covers logical thinking, inductive and deductive reasoning, and tools for programming including algorithms, flowcharts, and pseudocode. Top-down structured programming is introduced as breaking a program into modules to make it easier to understand.

Uploaded by

siddhanthajare07
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)
7 views20 pages

Unit 1

The document discusses computational thinking and its key concepts including decomposition, abstraction, pattern recognition, and algorithms. It also covers logical thinking, inductive and deductive reasoning, and tools for programming including algorithms, flowcharts, and pseudocode. Top-down structured programming is introduced as breaking a program into modules to make it easier to understand.

Uploaded by

siddhanthajare07
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/ 20

UNIT-1.

Introduction to Programming Languages

Computational Thinking (CT)


What is CT?

 Computational thinking is the thought processes involved in formulating a problem and


expressing its solution(s) in such a way that a computer—human or machine—can
effectively carry out.’

 The mental activity for abstracting problems and formulating solutions that can be
automated
 Computational thinking is the step that comes before programming. It’s the process of
breaking down a problem into simple enough steps that even a computer would
understand.

Purpose of CT
1. CT can be applied by anyone who is attempting to solve a problem and have a computer
play a role in the solution.

2. Computational thinking allows us to take a complex problem, understand what the


problem is and develop possible solutions

3. Computational thinking is useful to enables real-world problem solving.

4. CT enables us to take large problems and break them into simpler steps can help with
everything from solving

5. computational thinking encourages people to approach any problem in a systematic


manner, and to develop and articulate solutions in terms that are simple enough to be
executed by a computer – or another person

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


CT and Problem-Solving Strategies / Four Pillar of computational
thinning

This brings us to the four key techniques of computational thinking:


1. Decomposition - breaking down a complex problem or system into smaller, more manageable
parts (e.g.where to go, how to complete the level)
2. Abstraction - focusing on the important information only, ignoring irrelevant details (e.g.
weather, location of exit)
3. Pattern recognition – looking for similarities among and within problems (e.g. knowledge of
previous similar problems used)
4. Algorithms - developing a step-by-step solution to the problem, or the rules to follow to solve
the problem (e.g. to work out a step-by-step plan of action)

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


Logical Thinking
Logic includes a set of principles that, when applied to arguments, allow us to demonstrate what
is true.
You need no special training to begin doing this, as this classic introductory example of a logical
argument demonstrates:

1. Socrates is a man.
2. All men are mortal.
3. Therefore, Socrates is mortal.

logic is a system used for distinguishing between correct and incorrect arguments.
we mean the philosophical idea of an argument; namely a chain of reasoning that ends up in a
conclusion.

Inductive arguments

Inductive reasoning is a logical thinking process in which specific observations that are believed
to be true are combined to draw a conclusion to create broader generalizations and theories
Example :
1. Socrates is a man.
2. All men are mortal.
3. Therefore, Socrates is mortal.

Deductive arguments

Deductive reasoning, on the other hand, works in the opposite direction of inductive reasoning. It
is a logical thinking process that uses the top-down approach to go from the more general to the
more specific

1. All tennis balls are round.


2. The Earth is round.
3. Therefore, the Earth is a tennis ball.

This argument fails because of faulty logic

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


Program planning tools - algorithm, flowchart, and pseudo code

Algorithm:
Definition: An algorithm is a step-by-step method for solving some problem. An algorithm
refers to a set of instructions that define the execution of work to get the expected results.
 To make the program work properly, we must have to properly design the algorithm.
Designing the algorithm helps to utilize the computing resources effectively.
 It uses plain text, which is written in plain English language.
 The algorithm is easy to debug.
 There are no rules employed for algorithms.
 Algorithms are the program's pseudo-code
.

Flowchart
Definition: A diagrammatic representation of an algorithm is called a flow chart.
 A flowchart is a graphical representation of an algorithm.
 A flowchart can be helpful for both writing programs and explaining the program to
others.
 A flowchart is a diagram created with different shapes to show the flow of data.
 It uses various symbols to show the operations and decisions to be followed in a program
 The process of drawing a flowchart for an algorithm is known as “flowcharting”

Symbols used in flowchart are mentioned below –

Name Symbol Purpose

Terminal Start/stop/begin/end Of flow


chart

Oval

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


Name Symbol Purpose

Input/output Input/output of data

Parallelogram

Process Any processing to be


performed can be represented

Rectangle

Decision box Decision operation that


determines which of the
alternative paths to be
followed

Diamond

Connector Used to connect different


parts of the flowchart

Circle

Flow Join 2 symbols and also


represent flow of execution

Arrows

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


Name Symbol Purpose

Pre-defined Module (or) subroutines


process specified elsewhere

Double
Sided Rectangle

Page connector Used to connect flowcharts in


2 different pages

Pentagon

For loop shows initialization,


symbol condition, and increment of
the loop variable

Hexagon

Document Shows the data that is ready


for printout

Printout

pseudocode
 Pseudocode is a simple way of writing programming code in English
 Pseudocode is not actual programming language. It uses short phrases to write code for
programs before you actually create it in a specific language

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


 Once you know what the program is about and how it will function, then you can use
pseudocode to create statements to achieve the required results for your program.
 Pseudocode does not have a specific syntax
 Writing pseudocode allows you to get those brilliant ideas in your head in front of you
without having to worry about the syntax of the programming language.

Examples of Pseudocode
1. pseudocode to create a program to add 2 numbers together and then display the
result

Start Program
Enter two numbers, A, B
Add the numbers together
Print Sum
End Program

2. Now, let's look at an example of pseudocode to compute the perimeter of a rectangle:

Enter length, l
Enter width, w
Compute Perimeter = 2*l + 2*w
Display Perimeter of a rectangle

Remember, writing a basic pseudocode is not like writing an actual coding language.
It cannot be compiled or run like a regular program.

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


Introduction to top –down structured programming
 Top-down programming focuses on the use of modules.
 It is therefore also known as modular programming.
 The program is broken up into small modules so that it is easy to trace a particular
segment of code in the software program.
 Structured programming generally makes use of top-down design because program
structure is divided into separate subsections
 TOP DOWN APPROACH - In top down approach execution of a program starts
from the MAIN() function and then go to its respective functions.

Top-down Approach start from main() function and go to the respective function down the
order. So, basically all C program execution start from top the order i.e; from main() function
and go to down the order, i.e; it is said as top-down approach. Here is the pictorial view:-

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


So basically all C programs follow top-down approach let’s take a example -

#include<stdio.h>
void main()
{
int a,b;
clrscr();
printf("Enter Two Number : ");
scanf("%d%d",&a,&b);
sum(a,b);
getch();
}
sum(int x,int y)
{
int z;
z=x+y;
printf("Sum of Two Number is : %d",z);
return 0;
}

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


In this program Sum of two Numbers can be performed Here we use a function sum which will
calculate sum of number present on variable a and b When the execution start the compiler first
execute main function then it executes function [module] sum.

Structured programming
1. Structured programming generally makes use of top-down design because program
structure is divided into separate subsections
2. Structured programming (sometimes known as modular programming) is a programming
paradigm that facilitates the creation of programs with readable code and reusable
components
3. C is called structured programming language because a program in c language can be
divided into small logical functional modules or structures with the help of function
procedure.
4. It encourages top-down implementation, which improves both readability and
maintainability of code.
5. Structured programming encourages dividing an application program into a hierarchy of
modules
6. Structured programming languages are simple and easy to understand because
programmers do not require knowing complex design concepts to start a new program.

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


Compiler

A compiler is also a type of system software used to convert high-level programming


languages into executable machine codes or low-level programming languages

Interpreter

Interpreter is also used to perform the same function. But the only difference is that
compiler translates the whole program at once while the interpreter converts each line
individually.

Types of Program Errors: Syntax, logical, runtime, Debugging

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


Syntax Error:
Errors occur when you violate the rules of writing C syntax is said to be “Syntax errors”
This compiler error indicates that this must be fixed before the code will be compiled.
These errors are identified by the compiler so these errors are called “compile-time errors”.

Runtime Error

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


 Runtime Error: A runtime error in a program is an error that occurs while the program
is running after being successfully compiled.
 Errors which are occurred after a successful compilation of program is said to be “run-
time errors”.
 Number divisible by zero, array index out of bounds, string index out of bounds, etc. are
most frequent run-time errors

Output :

Logical Errors

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


A logic error (or logical error) is a mistake in a program's source code that results in
incorrect or unexpected behavior.
A logic error is a condition encountered by a computer program where a result is not
logically correct, but is not reported as an error
If our expectation is one thing and result output is other thing then that kind of error we said it as
“Logical errors”.

 Let suppose if we want sum of the 2 numbers but given output is the multiplication of 2
numbers then this said to be Logical error.
 It can be detected by line by line debugging.

Output
Sum is 200

But expected of above program is output is 30

Debugging

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


 Debugging is the process of detecting and removing of existing and potential errors (also

called as ‘bugs’) in a program code that can cause it to behave unexpectedly or crash.

 debugging is used to find and resolve bugs or defects

 Debugging tools (called debuggers) are used to identify coding errors at various

development stages. They are used to reproduce the conditions in which error has

occurred, then examine the program state at that time and locate the cause.

 Programmers can trace the program execution step-by-step by evaluating the value of

variables and stop the execution wherever required to get the value of variables or reset

the program variables.

 Some programming language packages provide a debugger for checking the code for

errors while it is being written at run time.

EXAMPLES OF ALGORITHMS AND FLOW CHARTS WITH C CODE.

Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]


Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]
Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]
Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]
Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]
Asst. Prof. Dhamale Nitin D. [IT Dept.] F.Y. B. Tech [KKWIEER]

You might also like