0% found this document useful (0 votes)
67 views37 pages

Introduction To Computer Programming CSIR11

Uploaded by

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

Introduction To Computer Programming CSIR11

Uploaded by

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

INTRODUCTION TO COMPUTER PROGRAMMING

CSIR11
• COURSE LEARNING OBJECTIVES
• To learn the fundamentals of computers.
• To learn the problem-solving techniques writing algorithms &
procedures.
• To learn the syntax and semantics for C programming language.
• To develop the C code for simple logic.
• To understand the construct of structure program including
conditionals and iterations
COURSE CONTENT
• Introduction to computers - Types of programming languages-
Developing a program - Algorithms- Characteristics- Flow Charts-
Principles of structured programming- Sequential selecting structures-
Repetitive Structures-Bounded, Unbounded and Infinite iterations.
• Introduction to C- C character set- Identifiers and Keywords- Data types-
Constants- Variables- Declarations- Expressions- Statements- Symbolic
Constants- Operators- Library Functions- Data input and output: Single
character input and output- Entering input data- Writing output data-
gets and puts functions - Control Statements- Branching: if-else-looping:
while- do-while-for; Nested control Structures- switch statements- Break
statements- Continue Statements-Comma operator- goto statements.
COURSE CONTENT
• Modular Programming- Functions and Procedures - Examples- Parameters
passing methods - Arrays- Defining an array- Processing an array- Multi
dimensional arrays- Pointers- Variables definitions and initializations- Pointer
operators- Pointer expressions and arithmetic- Pointers and one dimensional
arrays - String operations.
• Functions- Defining function- Accessing a function- Function prototypes-
Passing arguments to a functions- Passing arrays to a function- Passing
Pointers to function- Recursion – Dynamic memory allocation - malloc, calloc,
realloc – Structures – Declaration – Structures and Functions – Arrays of
Structures – Pointers to structures – Typedef - Unions – Bit-fields.
• Files – Input / Output using files – fread, fwrite, fprintf, fscanf – Formatted
input – File access - argc, argv.
REFERENCE BOOKS
1. Byron Gottfried, Programming with C, 3rd Edition, Tata McGraw Hill
Education, 2010.
2. R.G. Dromey, How to solve it by Computers? Prentice Hall, 2011.
3. Brian W Kernighan and Dennis Ritchie, The C Programming language,
2nd Edition, Prentice Hall, 1988.
4. J.R.Hanly and E.B. Koffmann, Problem Solving and Program design in C,
6th Edition, Pearson Education, 2009.
5. Paul Deital and Harvey Deital, C How to Program? 7th Edition, Prentice
Hall, 2012.
6. YashvantKanetkar, Let Us C, 12th Edition, BPB Publications, 2012.
COURSE OUTCOME
• Ability to write algorithms for problems
• Knowledge of the syntax and semantics of C programming language
• Ability to code a given logic in C language
• Knowledge in using C language for solving problems
CSIR11-INTRODUCTION TO
COMPUTER PROGRAMMING
UNIT I
(Introduction to computers - Types of programming languages- Developing a program -
Algorithms- Characteristics- Flow Charts-Principles of structured programming- Sequential
selecting structures- Repetitive Structures-Bounded, Unbounded and Infinite iterations.)
DATE: 29/08/2023
Computer
• Computer : is an electronic device that operates
(works) under the control of programs stored in its own
memory unit.
A computer is an electronic machine that processes
raw data to give information as output.

An electronic device that accepts data as input and


transforms it under the influence of a set of special
instructions called Programs, to produce the desired
output (referred to as Information).
Program
• A computer Program is a set of related instructions
written in the language of the computer & is used to
make the computer perform a specific task (or, to direct
the computer on what to do).
• A set of related instructions which specify how the data
is to be processed.
A set of instructions used to guide a computer through a
process.
Data
• Is a collection of raw facts, figures or instructions that
do not have much meaning to the user.

­Data may be in form of numbers, alphabets/letters or


symbols, and can be processed to produce information.
Processing & Information
• Processing refers to the way the data is manipulated
(or handled) to turn it into information.
The processing may involve calculation, comparison or
any other logic to produce the required result. The
processing of the data usually results in some
meaningful information being produced.

Information: is the data which has been refined,


summarized & manipulated in the way you want it, or
into a more meaningful form for decision-making. ­The
information must be accurate, timely, complete and
relevant.
Computer Organization
Characteristics / Features of a Computer
• Speed
• The speed of a computer is measured in Fractions of seconds.
Millisecond
Microsecond
Nanosecond
Picosecond
• Accuracy
• Reliability: as reliable as the instructions used & the data
supplied
• Consistency: given the same data & the same instructions,
they will produce the same answer every time that particular
process is repeated.
Characteristics / Features of a Computer
• Storage:
• A computer is capable of storing large amounts of data or
instructions in a very small space.
• Diligence:
• can work continuously without getting tired or bored. Even if it
has to do a million calculations, it will do the last one with the
same speed and accuracy as the first one.
• Automation
• A computer is an automatic device. This is because, once
given the instructions, it is guided by these instructions and
can carry on its job automatically until it is complete.
Characteristics / Features of a Computer
• Versatile:
• A computer can be used in different places to perform a large
number of different jobs depending on the instructions fed to
it.
• Imposition of a formal approach to working methods:
• Because a computer can only work with a strict set of
instructions, it identifies and imposes rigid rules for dealing
with the data it is given to process.
Computer Hardware
• Hardware refers to the physical components of a
computer. Computer Hardware is any part of the
computer that we can touch these parts. These are the
primary electronic devices used to build up the
computer.
• Examples of hardware in a computer are the Processor,
Memory Devices, Monitor, Printer, Keyboard, Mouse,
and the Central Processing Unit.
Computer Software
• Software is a collection of instructions, procedures, and
documentation that performs different tasks on a
computer system. we can say also Computer Software
is a programming code executed on a computer
processor. The code can be machine-level code or the
code written for an operating system.
• Examples of software are Ms Word, Excel, PowerPoint,
Google Chrome, Photoshop, MySQL, etc.
S. No. Parameters Hardware Software

Hardware is a physical part of the computer that Software is a set of instructions that tells a computer exactly
1. Basic Definition causes the processing of data. what to do.

Difference
2.

3.
Development

Dependency
It is manufactured. It is developed and engineered.

Hardware cannot perform any task without software. The software can not be executed without hardware.

Process of Electronic and other materials are used to create


4. Created by utilizing a computer language to write instructions.
creating hardware.

Hardware is tangible as hardware is a physical Software is intangible as we can see and also use the software
5. Tangible electronic device, that can be touched. but can’t touch them.

The software does not wear out with time. However, it may
6. Durability Hardware typically wears out over time. contain flaws and glitches.

It has four main categories: input devices, It is mainly divided into System software and
7. Types output devices, storage, and internal components. Application software.

8. Virus effect Hardware is not affected by computer viruses. Software is affected by computer viruses.

It cannot be transferred from one place to another


9. Transfer electrically through the network. It can be transferred via a network means.

Machine-Level Only machine-level language is known to be The program accepts human-readable input, interprets it in
10. machine-level language, and sends it to hardware for additional
language understood by hardware. processing.

If hardware is damaged, it is replaced with a new


11. Replacement one. If the software is damaged, its backup copy can be reinstalled.

Dust, overheating, humidity and other factors are Overloading, systematic error, major-minor version error, and
12. Failures commonly responsible for hardware failures. other factors are commonly responsible for software failures.

Ex: Keyboard, Mouse, Monitor, Printer, CPU,


13. Examples Hard disk, RAM, ROM, etc. Ex: MS Word, Excel, PowerPoint, Photoshop, MySQL, etc.
Modes of Operation
Kernel Mode and User Mode
• An Operating System (OS) is an interface between a computer user and computer hardware.
• An operating system is a software which performs all the basic tasks like file management, memory
management, process management, handling input and output, and controlling peripheral devices
such as disk drives and printers.
• Because an operating system must hide the computer's hardware, and manage the hardware
resources, it needs to prevent the application software from accessing the hardware directly. Without
this sort of protection, the operating system would not be able to do its job.
• The computer's CPU provides two modes of operation which enforce this protection. The operating
system runs in kernel mode, also known as supervisor mode or privileged mode. In kernel mode, the
software has complete access to all of the computer's hardware, and can control the switching
between the CPU modes. Interrupts are also received in the kernel mode software.
• The rest of the software runs in user mode. In this mode, direct access to the hardware is prohibited,
and so is any arbitrary switching to kernel mode. Any attempts to violate these restrictions are
reported to the kernel mode software: in other words, to the operating system itself. Programs running
in user mode are given an address space, visible only to themselves, which contains enough memory
for them to do their job.
Kernel Mode and User Mode
Kernel Mode and User Mode
• System call:
• When there is a requirement of hardware resource, the process sends a request
to the kernel to get the process access and then computer enters in kernel
mode. These requests are sent by using system call. The computer switches
between these two mode frequently. Whenever the task is completed, the
computer goes back to the user mode from kernel mode. This mode of transition
is called context switching.
• Library Call :
• A Library call is a kind of request to use a specific piece of function that is defined
in a programming library. A library file contains code data file, object file that are
packed into one file for use. To make a library call, library should be imported
first. The library call may be depended on the system call to complete the task.
Programming Languages
• A programming language is a computer language that is used
by programmers (developers) to communicate with computers. It is
a set of instructions written in any specific language ( C, C++, Java,
Python) to perform a specific task.
• Types
• Procedural programming languages
• A procedural language follows a sequence of statements or commands in
order to achieve a desired output. Each series of steps is called a procedure,
and a program written in one of these languages will have one or more
procedures within it.
Programming Languages
• Functional programming languages
• Rather than focusing on the execution of statements, functional languages
focus on the output of mathematical functions and evaluations. Each
function–a reusable module of code–performs a specific task and returns a
result. The result will vary depending on what data you input into the
function.
• Object-oriented programming languages
• This type of language treats a program as a group of objects composed of
data and program elements, known as attributes and methods. Objects can
be reused within a program or in other programs. This makes it a popular
language type for complex programs, as code is easier to reuse and scale.
Programming Languages
• Scripting languages
• Programmers use scripting languages to automate repetitive tasks, manage
dynamic web content, or support processes in larger applications.
• Logic programming languages
• Instead of telling a computer what to do, a logic programming language
expresses a series of facts and rules to instruct the computer on how to make
decisions.
Developing a Program
Algorithm
• An algorithm is a set of commands that must be followed for a computer to
perform calculations or other problem-solving operations.
• According to its formal definition, an algorithm is a finite set of instructions
carried out in a specific order to perform a particular task.
• It is not the entire program or code; it is simple logic to a problem represented as
an informal description in the form of a flowchart or pseudocode.
Characteristics
Algorithm Examples
Problem 1: Find the area of a Circle of radius r.
Inputs to the algorithm: Radius r of the Circle.
Expected output: Area of the Circle
Algorithm:
Step1: Read\input the Radius r of the Circle
Step2: Area PI*r*r // calculation of area
Step3: Print Area
Algorithm Examples
Problem2: Write an algorithm to read two numbers and find their sum.
Inputs to the algorithm:
First num1.
Second num2.
Expected output:
Sum of the two numbers.
Algorithm:
Step1: Start
Step2: Read\input the first num1.
Step3: Read\input the second num2.
Step4: Sum num1+num2 // calculation of sum
Step5: Print Sum
Step6: End
Algorithm Examples
Problem 3: Convert temperature Fahrenheit to Celsius (Homework)
Flowchart
• a diagram which visually presents the flow of data through processing
systems- the operations performed and the sequence of these operations in a
system.
• can be used for representing an algorithm.
• a blueprint of a design you have made for solving a problem.
• For example
• Suppose you are going for a picnic with your friends then you plan for the activities you
will do there. If you have a plan of activities, then you know clearly when you will do
what activity.
• Similarly, when you need to write a computer program for a problem then it will be
good to draw a flowchart prior to writing a computer program.
• Flowchart is drawn according to defined rules.
Flowchart Symbols
Flowchart rules
• All boxes of the flowchart are connected with Arrows. (Not lines)
• Flowchart symbols have an entry point on the top of the symbol with no other entry points. The
exit point for all flowchart symbols is on the bottom except for the Decision symbol.
• The Decision symbol has two exit points; these can be on the sides or the bottom and one side.
• Generally, a flowchart will flow from top to bottom. However, an upward flow can be shown as
long as it does not exceed 3 symbols.
• Connectors are used to connect breaks in the flowchart. Examples are: • From one page to
another page. • From the bottom of the page to the top of the same page. • An upward flow of
more then 3 symbols
• Subroutines and Interrupt programs have their own and independent flowcharts.
• All flow charts start with a Terminal or Predefined Process (for interrupt programs or
subroutines) symbol.
• All flowcharts end with a terminal or a contentious loop.
Flowchart Examples
• Problem1: Find the area of a circle of radius r.
Flowchart Examples
• Problem 2: Convert temperature Fahrenheit to Celsius.(Homework)
Flowchart Examples
• Problem 3: Find the greater number between two numbers
Flowchart Examples
• Problem 4: Flowchart for the problem of printing odd numbers less
than a given number. It should also calculate their sum and count.

You might also like