C Programming
C Programming
Programming in C
(25UAI101)
UNIT 1
Introduction to Problem
Solving Techniques :
Fundmentals
What is a program ?
A program is a sequence of instructions that specifies
how to perform a computation.
It is written in a language the computer understands.
The computation might be something mathematical,
such as
solving a system of equations or finding the roots of a
polynomial.
a symbolic computation, such as searching and
replacing text in a document or (strangely enough)
compiling a program.
Programming: a way of thinking
The single most important skill for a
computer scientist is problem solving.
Problem solving means the ability to
formulate problems, think creatively about
solutions, and express a solution clearly
and accurately.
Development of Computer
Solution
1. Identify or Define the problem
2. Analyze the problem in terms of inputs,
outputs, formulas, constants)
3. Design the Solution
4. Implement (program coding)
5. Evaluate
Program Components
A few basic instructions appear in every language:
Input - Get data from the keyboard, a file, or some other
device.
Output - Display data on the screen or send data to a file
or other device.
Math Perform basic mathematical operations like
addition and multiplication.
Conditional execution - Check for certain conditions
and execute the appropriate sequence of statements.
Repetition/Looping - Perform some action repeatedly,
usually with some variation.
What is debugging?
Programming errors are called bugs and the process of tracking them
down and correcting them is called debugging.
Three kinds of errors can occur in a program:
1. Syntax errors
A program can only be executed if it is syntactically correct; otherwise,
the process fails and returns an error message.
syntax refers to the structure of a program and the rules about that
structure.
2. Runtime errors
So called because the error does not appear until you run the program.
These errors are also called exceptions because they usually indicate
that something exceptional (and bad) has happened.
3. Semantic errors
If there is a semantic error in the program, it will run successfully, in the
sense that the computer will not generate any error messages, but it will
not do the right thing. It will do something else. Specifically, it will do
what the programmer told it to do.
But the written program does not solve the original problem. The
meaning of the program (its semantics) is wrong.
Information Processing System
DATA is a collection of independent and
unorganized facts.
INFORMATION is the processed and
organized data presented in a meaningful
form.
DATA PROCESSING is the course of
doing things in a sequence of steps.
Information Processing System
COMPUTER is an electronic machine that
follows a set of instructions in order that it
may be able to accept and gather data
and transform these into information.
PROCESSING
SYSTEM
DATA INFORMATION
Functions of an Information
Processing System
1. It accepts and gather data. (INPUT)
2. It processes data to become information.
(PROCESSING)
3. It stores data and information. (STORE)
4. It presents information. (OUTPUT)
Three Major Components of an
Information Processing System
HARDWARE is the tangible part of a
computer system.
SOFTWARE is the non-tangible part that
tells the computer how to do its job.
PEOPLEWARE refer to people who use
and operate the computer system, write
computer programs, and analyze and
design the information system.
Basic Units of Measurement
Data is measured in bits and bytes.
A bit is the smallest unit, representing a 0 or 1.
A byte, consisting of 8 bits
It is the fundamental unit for storing characters
or numbers.
Basic Units of Measurement
1,000 bytes = 1 kilobyte (K or KB)
1,000 KB = 1 megabyte (MB)
1,000 MB = 1 gigabyte (GB)
1,000 GB = 1 Terabyte (TB)
1,000 GB = 1 Terabyte (TB)
1,000 TB = 1 Petabyte (PB)
1,000 PB = 1 Exabyte (EB)
1,000 EB = 1 Zettabyte (ZB)
1,000 ZB = 1 Yottabyte (YB)
HARDWARE
Hardware refers to the physical parts of a
computer and related device.
Hardware devices include motherboard,
hard drive and RAM.
Hardware is the ‘soul’ of the computer.
Basic hardware of a PC system
Central Processing Unit (CPU)
Memory Unit
Input Devices
Output Devices
Secondary Storage Devices
1. Central Processing Unit
Brain of the computer.
It directs and controls the entire computer
system and performs all arithmetic and
logical operations.
2. Memory Unit
Where the programs and
data are stored .
READ ONLY MEMORY
(ROM) contains the pre-
programmed computer
instructions such as the Basic
Input Output System (BIOS).
RANDOM ACCESS
MEMORY (RAM) is used to
store the programs and data
that you will run. Exists only
when there is power.
3. Input Devices
Allows data and programs to be sent to
the CPU.
Keyboard
Mouse
Joystick
Microphone
Webcam
Scanner
Monitor
4. Output Devices
Media used by the computer in displaying
its responses to our requests and
instructions.
Monitor
Audio Speakers
Printer
5. Secondary Storage Devices
Attached to the computer system to allow
you to store programs and data
permanently for the purpose of retrieving
them for future use.
Floppy disk, Hard disk, CD Rom
Software
A set of instructions and its
documentations that tells a computer what
to do or how to perform a task.
Software and programs are
interchangeable.
Two major types:
System and Applications
Kinds of Software
System software is software designed to provide a
platform for other software.
Examples of system software include operating
systems like macOS, Linux OS and Microsoft
windows.
Application software is a program or group of
programs designed for end users.
Examples of an application include a word processor,
a spreadsheet, an accounting application, a web
browser, an email client.