0% found this document useful (0 votes)
19 views

Programming Languages Unit - I

This document provides an introduction to C programming and program development. It discusses main memory, which consists of both RAM and ROM. RAM is read-write memory that is volatile, while ROM is read-only and permanent. It also describes different types of computers including mainframes, minicomputers, workstations, microcomputers, and supercomputers. Finally, it covers software, distinguishing between application software like Microsoft Office, and system software which runs the computer hardware and applications.

Uploaded by

Vinoth Kumar M
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views

Programming Languages Unit - I

This document provides an introduction to C programming and program development. It discusses main memory, which consists of both RAM and ROM. RAM is read-write memory that is volatile, while ROM is read-only and permanent. It also describes different types of computers including mainframes, minicomputers, workstations, microcomputers, and supercomputers. Finally, it covers software, distinguishing between application software like Microsoft Office, and system software which runs the computer hardware and applications.

Uploaded by

Vinoth Kumar M
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 88

C PROGRAM

PROGRAM DEVELOPMENT &


INTRODUCTION TO C
UNIT - 1
PROGRAM DEVELOPMENT & INTRODUCTION TO C

• The main memory also known as the primary


memory is a part of the central processing unit
and is a combination of both RAM (random
access memory) and ROM (read only
memory).
• RAM
• The random access memory is a read write
memory i.e. information can be read as well as
written into this type of memory.
• It is volatile in nature, i.e., the information it
contains is lost as soon as the system is shut
down unless 'saved' for further usage by
users.
• It is basically used to store programs and data
during the computer’s operation.
• ROM
• The read only memory as the name may
suggest contains information that can only be
read, i.e., you can’t write on this type of
memory.
• It is non-volatile or permanent in nature.
• It is basically used to store permanent
programs such as program for the functioning
of the monitor.
Types of computer
• Mainframe Systems:

A mainframe is the largest computer, a powerhouse with massive


memory and extremely rapid processing power. It is used for very large
commercial, scientific, or military applications where a computer must
handle massive amounts of data or many complicated processes.

There are several organizations such as banks, insurance companies,


hospitals, railways, etc. Mainframe systems are computer systems, that
need on-line processing of large number of transactions, and require
computer systems, which have massive data storage and Processing
capabilities.
In early days of computing Mainframes are big
Computers that can fill the entire room or entire floor.
Mainframes are mainly used by large organizations for
Critical applications, such as consumer statistics, and
financial transaction processing.
Large organizations use mainframes for highly critical
applications such as bulk data processing and ERP. Most
of the mainframe computers have the capacities to host
multiple operating systems and operate as a number of
virtual machines and can thus substitute for several small
servers.
Mainframe Computer
Minicomputers
 Multi-user systems that can handle the
computing needs of a smaller corporation or
organization.
 Many people use them simultaneously by
means of remote terminals or personal
computers.
 The mini computers came which offered user’s
different applications, most famous of these
the word processors and spreadsheet which
could be used by non technical users.
 In terms of size and processing capacity,
minicomputers lie in between mainframes and
microcomputers. Minicomputers are also
called mid-range systems or workstations.
 Minicomputers are lie between the
Mainframe computer and small Personal
Computers.
 Minicomputers also refereed to Mid-Range
Servers. Minicomputers are more powerful but
still compatible version of a personal
computer.
 A minicomputer is a middle-range computer,
about the size of an office desk, often used in
universities, factories, or research Laboratories.
Workstations:
A workstation is a powerful Desktop Computer
designed for technical or scientific
applications. Intended primarily to be used by
one person at a time, they are commonly
connected to a local area network and run
multi-user operating systems. The term
workstation has also been Used to refer to a
PC connected to a network.
A computer that has a more power resources like Processing
Power, Memory and additional capabilities to perform special task
refers to as workstation. Workstations are often optimized for
displaying and manipulating complex data such as 3D mechanical
design, engineering simulation results such as for computational
fluid dynamics, animation and rendering of images, and
mathematical plots.
A workstations also fits on a desktop but has more powerful
mathematical and graphics processing capability than a micro
computer. Workstations are used for scientific, engineering, and
design work that requires powerful graphics or computational
capabilities.
Microcomputers:
A micro-computer is one that can be placed on a desktop
or
carried from room to room. Microcomputers are used as personal
machines as well as in business. A computer with a
microprocessor
And its central processing unit is known as a microcomputer. They
do Not occupy space as much as mainframes. When
supplemented
with a keyboard and a mouse, microcomputers can be called as
personal computers. These computers can fit on desks or tables
and serve as the best choices for single user tasks.
Super computers:
A super computer is a highly sophisticated and powerful
Machine that is used for tasks requiring extremely rapid and
complex calculations with hundreds of thousands of variable
factors. Supercomputers have traditionally been used in scientific
and military work, but they are starting to be used in business as
well. The problem with this classification scheme is that the
capacity of the machines changes so rapidly.
A computer which, among existing general-purpose
computers at any given time, is superlative, often in several senses:
highest computation rate, largest memory, or highest cost.
machines designed to perform numerical Calculations at the
highest speed that the latest electronic device technology and the
state of the art of computer architecture allow.
Supercomputers are the most powerful and expensive
computers available at a given time. They are primarily
used for processing complex scientific applications,
which
require enormous processing power.
Some of the supercomputing applications are as
follows:
• Aerospace industry.
• Petroleum industry
• Automobile industry.
• Structural mechanics industry
Super computers
Personal Computer (PC):
A personal computer (PC) is a computer
whose original sales price, size, and capabilities
make it useful for individuals, and intended to be
operated directly by an end user, with no intervening
computer operator. People generally relate this term
with Microsoft’s Windows Operating system.
Personal computers generally run on Windows, Mac
or some version of Linux operating system.
Personal computers come in a variety of forms such as
desktops, laptops and personal digital assistants. Let us
look at each of these types of computers.
Desktops:
A desktop is intended to be used on a single location. The
spare parts of a desktop computer are readily available at
relative lower costs. Power consumption is not as critical
as that in laptops. Desktops are widely popular for daily
use in workplaces and households.
Desktop computer is just another version of Personal
Computer intended for regular use from a single use. A
computer that can be fit on a desk can also be called as
desktop. A desktop computer comes in different form
vertical tower cases to small form factor.
Laptops:
Similar in operation to desktops, laptop computers are
miniaturized and optimized for mobile use. Laptops run on a single
battery or an external adapter that charges the computer batteries.
They are enabled with an inbuilt keyboard, touch pad acting as a
mouse and a liquid crystal display. Its portability and capacity to
operate on battery power have served as a boon for mobile users.
Laptop computer, Laptop or Notebook all are same. Laptop’s are
generally small mobile computers run on a single main battery or
From an external power supply that will served as to run the laptop
As well as charge the battery. Laptop contains all the components
of computer but all these are optimized for mobile users.
Personal Digital Assistants (PDAs):
It is a handheld computer and popularly
known as a palmtop. It has a touch screen and a
Memory card for storage of data. PDAs can also
Be effectively used as portable audio players,
Web browsers and smart phones. Most of them
Can access the Internet by means of Bluetooth
Or Wi-Fi communication.
• SOFTWARE
• Sometimes abbreviated as SW and S/W, software is a
collection of instructions that enable the user to
interact with a computer, its hardware, or perform
tasks.
• Without software, most computers would be useless.
• For example, without your Internet browser software,
you could not surf the Internet or read this page.
• Without an operating system, the browser could not
run on your computer.
• The picture shows a Microsoft Excel box, an example
of a spreadsheet software program.
• There are two types of software −
• Application Software
• System Software
• Application Software
• Application software, or app for short, is software that
performs specific tasks for an end-user.
• For example, Microsoft Word or Excel are application
software, as are common web browsers such as Firefox or
Google Chrome.
• Another example, such as Microsoft's notepad for writing
and editing a simple text.
• It also includes the category of mobile apps, including
communication apps such as WhatsApp or games such as
Candy Crush Saga.
• There are also app versions of common services such as those
providing weather or transport information or apps for
customers to interact with companies.
• Examples of Application software are the
following −
• Payroll Software
• Student Record Software
• Income Tax Software
• Railways Reservation Software
• Microsoft Office Suite Software
• Microsoft Word
• Microsoft Excel
• Microsoft PowerPoint
• SYSTEM software
• Application software is distinct from system
software, which refers to the software that
actually keeps the systems running such as the
operating system.
• System software is a type of computer
program that is designed to run a computer's
hardware and application programs.
• System Software
• The system software is a collection of programs
designed to operate, control, and extend the
processing capabilities of the computer itself.
• System software is generally prepared by the
computer manufacturers.
• System software serves as the interface
between the hardware and the end users.
• Some examples of system software are
Operating System etc.
• ALGORITHM
• Algorithm is a step-by-step procedure, which defines a set of
instructions to be executed in a certain order to get the
desired output.
• data structure is a collection of data values, the
relationships among them, and the functions or operations
that can be applied to the data
• From the data structure point of view, following are some
important categories of algorithms −
• Search − Algorithm to search an item in a data structure.
• Sort − Algorithm to sort items in a certain order.
• Insert − Algorithm to insert item in a data structure.
• Update − Algorithm to update an existing item in a data
structure.
• Delete − Algorithm to delete an existing item from a data
structure.
• How to Write an Algorithm?
• As we know that all programming languages
share basic code constructs like loops (do, for,
while), flow-control (if-else), etc. These common
constructs can be used to write an algorithm.
• We write algorithms in a step-by-step manner,
but it is not always the case. Algorithm writing is
a process and is executed after the problem
domain is well-defined. That is, we should know
the problem domain, for which we are
designing a solution.
• Example
• Let’s try to learn algorithm-writing by using an example.
• Problem − Design an algorithm to add two numbers
and display the result.
• Step 1 − START
• Step 2 − declare three integers a, b & c
• Step 3 − define values of a & b
• Step 4 − add values of a & b
• Step 5 − store output of step 4 to c
• Step 6 − print c
• Step 7 − STOP
• Computer programming :
• Computer programming is the process that
professionals use to write code that instructs how a
computer, application or software program
performs.
• At its most basic, computer programming is a set of
instructions to facilitate specific actions.
• If you're wondering what a computer programmer
is, it's a professional that creates instructions for a
computer to execute by writing and testing code
that enables applications and software programs to
operate successfully.
• Peripheral
• A peripheral is a “device that is used to put
information into or get information out of the
computer.”
• There are three different types of peripherals:
• Input, used to interact with, or send data to the
computer (mouse, keyboards, etc.)
• Output, which provides output to the user from the
computer (monitors, printers, etc.)
• Storage, which stores data processed by the
computer (hard drives, flash drives, etc.)
• Common Peripherals
• Input
– Keyboard
– Computer mouse
– Graphic tablet
– Touchscreen
– Barcode reader
– Image scanner
– Microphone
– Webcam
– Game controller
– Light pen
– Scanner
– Digital camera
• Common Peripherals
• Output
– Computer display
– Printer
– Projector
– Speaker
• Storage devices
– Floppy disk drive
– Flash drive
– Disk drive
– Smartphone or Tablet computer storage
interface
– CD/DVD drive
• Data representation
• Computers use binary - the digits 0 and 1 - to
store data.
• A binary digit, or bit, is the smallest unit of
data in computing.
• It is represented by a 0 or a 1.
• Binary numbers are made up of binary digits
(bits), eg the binary number 1001.
• Utility software
• Utility software is software designed to help
analyze, configure, optimize or maintain a
computer.
• It is used to support the computer
infrastructure - in contrast to
application software, which is aimed at
directly performing tasks that benefit
ordinary users.
• Utility Software
• The Utility Software is system software that
helps to maintain the proper and smooth
functioning of a Computer System.
• It assists the Operating System to manage,
organize, maintain, and optimize the
functioning of the computer system.
• Utility Software performs certain tasks like virus
detection, installation, and uninstallation, data
backup, deletion of unwanted files, etc. Some
examples are antivirus software, file
management tools, etc.
• Flowcharts
• A flowchart is a diagram that represents a set
of instructions.
• Flowcharts normally use standard symbols to
represent the different types of instructions.
• These symbols are used to construct the
flowchart and show the step-by-step solution
to the problem.
• Flowchart Advantages
Flowcharts are easier to understand compare to
Algorithms.
• It helps us to understand Logic of given problem.
• It is very easy to draw flowchart in any word
processing software like MS Word.
• Using only very few symbol, complex problem can be
represented in flowchart.
• Software like RAPTOR can be used to check
correctness of flowchart drawn in computers.
• Flowcharts are one of the good way of documenting
programs.
• It helps us in debugging process.
• Program Development Life Cycle
• The program development life cycle is a set of
steps or phases that are used to develop a program
in any programming language.
• Generally, the program development life cycle
contains 6 phases, they are as follows….
• Problem Definition
• Problem Analysis
• Algorithm Development
• Coding & Documentation
• Testing & Debugging
• Maintenance
• 1. Problem Definition
• In this phase, we define the problem statement and
we decide the boundaries of the problem. In this
phase we need to understand the problem statement,
what is our requirement, what should be the output
of the problem solution. These are defined in this first
phase of the program development life cycle.
• 2. Problem Analysis
• In phase 2, we determine the requirements like
variables, functions, etc. to solve the problem.
• That means we gather the required resources to solve
the problem defined in the problem definition phase.
We also determine the bounds of the solution.
• 3. Algorithm Development
• During this phase, we develop a step by step
procedure to solve the problem using the specification
given in the previous phase. This phase is very
important for program development. That means we
write the solution in step by step statements.
• 4. Coding & Documentation
• This phase uses a programming language to write or
implement the actual programming instructions for
the steps defined in the previous phase. In this phase,
we construct the actual program. That means we
write the program to solve the given problem using
programming languages like C, C++, Java, etc.,
• Levels of Programming Languages
• Programming languages can be broadly
classified into three categories:
• MACHINE LANGUAGES
• ASSEMBLY LANGUAGES
• HIGH LEVEL LANGUAGES
• MACHINE LANGUAGES:
• Imagine them as the “native tongue” of the
computer, the language closest to the
hardware itself.
• Each unique computer has a unique machine
language.
• A machine language program is made up of a
series of binary patterns (e.g., 01011100)
which represent simple operations that can be
accomplished by the computer.
• ASSEMBLY LANGUAGES:
• They represent an effort to make programming easier
for the human.
• The machine language instructions are replaced with
simple pneumonic abbreviations (e.g., ADD, MOV).
• Thus assembly languages are unique to a specific
computer (machine).
• Prior to execution, an assembly language program
requires translation to machine language.
• This translation is accomplished by a computer
program known as an Assembler.
• Assemblers are written for each unique machine
language.
• HIGH LEVEL LANGUAGES:
• High-level languages, like C,C++, JAVA etc., are
more English-like and, therefore, make it
easier for programmers to “think” in the
programming language.
• High-level languages also require translation
to machine language before execution.
• This translation is accomplished by either a
compiler or an interpreter.
• Compilers translate the entire source code
program before execution.(Eg: C++, Java)
• What is C Programming Langauge?
• C is a general-purpose programming language that is extremely
popular, simple, and flexible to use. It is a structured
programming language that is machine-independent and
extensively used to write various applications, Operating
Systems like Windows, and many other complex programs like
Oracle database, Git, Python interpreter, and more.
• It is said that ‘C’ is a god’s programming language. One can say,
C is a base for the programming. If you know ‘C,’ you can easily
grasp the knowledge of the other programming languages that
uses the concept of ‘C’
• It is essential to have a background in computer memory
mechanisms because it is an important aspect when dealing
with the C programming language.
• History of C language
• The base or father of programming languages is ‘ALGOL.’
• It was first introduced in 1960.
• ‘ALGOL’ was used on a large basis in European countries.
• ‘ALGOL’ introduced the concept of structured programming to the
developer community.
• In 1967, a new computer programming language was announced called
as ‘BCPL’ which stands for Basic Combined Programming Language.
• BCPL was designed and developed by Martin Richards, especially for
writing system software.
• This was the era of programming languages. Just after three years, in
1970 a new programming language called ‘B’ was introduced by Ken
Thompson that contained multiple features of ‘BCPL.’
• This programming language was created using UNIX operating system at
AT&T and Bell Laboratories.
• Both the ‘BCPL’ and ‘B’ were system programming languages.
• In 1972, a great computer scientist Dennis
Ritchie created a new programming language
called ‘C’ at the Bell Laboratories.
• It was created from ‘ALGOL’, ‘BCPL’ and ‘B’
programming languages.
• ‘C’ programming language contains all the
features of these languages and many more
additional concepts that make it unique from
other languages.
• C’ is a powerful programming language which is strongly associated with
the UNIX operating system.
• Even most of the UNIX operating system is coded in ‘C’.
• Initially ‘C’ programming was limited to the UNIX operating system, but
as it started spreading around the world, it became commercial, and
many compilers were released for cross-platform systems.
• Today ‘C’ runs under a variety of operating systems and hardware
platforms.
• As it started evolving many different versions of the language were
released.
• At times it became difficult for the developers to keep up with the latest
version as the systems were running under the older versions.
• To assure that ‘C’ language will remain standard, American National
Standards Institute (ANSI) defined a commercial standard for ‘C’
language in 1989.
• Later, it was approved by the International Standards Organization (ISO)
in 1990. ‘C’ programming language is also called as ‘ANSI C’.
• Features of C Programming Language:
• Procedural Language
• Fast and Efficient
• Modularity
• General-Purpose Language
• Rich set of built-in Operators
• Libraries with rich Functions
• Middle-Level Language
• Portability
• Easy to Extend
• Compile and Run C Program
• To compile and run a C language program, you need a C
compiler.
• A compiler is a software that is used to compile and
execute programs.
• To set up a C language compiler in your
Computer/laptop, there are two ways:
• Download a full-fledged IDE like Turbo C++ or Microsoft
Visual C++ or DevC++, which comes along with a C
language compiler.
• Or, you can use any text editor to edit the program files
and download the C compiler separately and then run
the C program using the command line.
• Using an IDE - Turbo C
• We will recommend you to use Turbo C or
Turbo C++ IDE, which is the oldest IDE for C
programming. It is freely available over the
internet and is good for a beginner.
• Step 1: Open turbo C IDE(Integrated
Development Environment), click on File and
then click on New
• Step 2: Write a Hello World program that we
created - C Hello World program.
• Step 3: Click on Compile menu and then
on Compile option, or press the keys press Alt
+ F9 to compile the code.
• Step 4: Click on Run or press Ctrl + F9 to run
the code. Yes, C programs are first compiled to
generate the object code and then that object
code is Run.
• Important Features of a C Program
Every C program requires a main ( ) function. Use of more than one
main ( ) is illegal. The place main is where the program execution
begins.

C programs are written in lower case letters. However, uppercase


letters are used for symbolic names and output strings.

All the words in a program line must be separated from each other
by at least one space, or a tab, or a punctuation mark.

Every program statement must end with a semicolon.

All variables must be declared for their types before they are used
in the program.
• C Character Set :
• C uses the uppercase letters A to Z, the
lowercase letters a to z, the digits 0 to 9, and
certain special characters
Character Name
, comma
. period
; semicolon
: colon
? question mark
‘ apostrophe
| vertical bar
/ slash
\ backslash
Character Name
& ampersand
^ caret
* asterisk
- minus sign
+ plus sign
= assignment sign
< opening angle bracket or
> closing angle bracket or
Character Name
( left parenthesis
) right parenthesis
[ left bracket
] right bracket
{ left brace
} right brace
• Constants and Variables
• Variables
• A quantity whose value changes during the
execution of the program is called a variable.
• C variable refers to the name given to the memory
location to store data.
• A Variable name is formed with alphabets, digits
and a special character underscore (_).
• The following are some valid variable names
AD,BASIC_PAY ,volume, B12
• The following are some invalid variable names AB. ,
9A
• Program to Display "Hello, World!“

#include <stdio.h>
int main()
{
printf("Hello, World!");
}
Output:

Hello, World!
• Constants
• A Constant is a quantity whose value does not
change during program execution.
• Keywords and Identifiers
• Every C word is classified as either a keyword
or an identifier. All keywords have fixed
meanings and these meanings can not be
changed.
• float
• goto
• int
• char
• Expressions :
• An expression is a formula for computing a
value.
• It is a combination of operands and
operators arranged as per the syntax of the
language.
 Arithmetic expressions - contains only arithmetic
operators and operands. ex: x+z
 Relational expressions – connecting constants or
variable or arithmetic expression by relation operator
 It is used to find out the relationship between two
operands.
 Ex : A*A-B > C*C-D
 Logical expressions – formed by connecting
expressions by logical operator. The value of expression
is either True or False.
 Conditional expressions – It returns one value if
condition is True & returns another value if condition is
false
• The main ( ) function
• Every executable program must contain a
special function called main (), which is where
the program execution begins.
• Unformatted I/O Function
• we have functions for performing I/O of one
character at a time, known as character I/O
functions
• getchar ()
• Formatted I/O Functions :
• scanf ( ) Function – Formatted Input
function
• scanf( "%d", &b );
• Code Meaning
• %c read a single character
• %d read a decimal integer
• %f read a floating point value
• printf ( ) Function – Formatted Output
function

Printf (“format string”, list of variables);


EX : printf (" Sum of the numbers : ",c) ;
• Data Types
 Data types are means to identify the type of
data and the associated operation of handling
it.
 Data can be of many types.
– Built-in Data types:
– char
– int
– float
– void - void in C means "nothing" or "no-value". This is
used either with pointer declarations or with function
declarations
• Int - Used to denote an integer type. Used to
store whole numbers like 1, 2, 100, 1000, etc.
• Char - Used to denote a character type.
generally a single alphabet like 'a', 'B', etc.
• float - Used to denote a floating point type.
Decimal point or real numbers values
like 99.9, 10.5, etc.
• Double - Very large numeric values which are
not allowed in Integer or Floating point type.
#include <stdio.h>
int main()
{
int a = 4000; // positive integer data type
float b = 5.2324; // float data type
char c = 'Z'; // char data type
}

You might also like