尊敬的 微信汇率:1円 ≈ 0.046166 元 支付宝汇率:1円 ≈ 0.046257元 [退出登录]
SlideShare a Scribd company logo
C -PROGRAMMINIG
UNIT -1
INDEX
• Algorithm and Flow-chart
• Introduction to Computers
• Creating and Running Programs
• Computer Numbering Systems
• Storing Integers
• Storing Real-numbers
• Introduction to C- Language:
• Background
• C-Programs
• Identifiers
• Variables
• Type Constants
• Input/Output
• Programming Examples
• Structure of C
• Type conversion Statements
• Sample Programs
Algorithms /Pseudocode
• Algorithm is the step-by-step method of performing any task.
• When we breakup a big task into smaller steps, what we actually do is to
create an Algorithm.
• Each step can be called an Instruction.
• In technical terms, an algorithm is an organized logical sequence of actions
or approach towards a particular problem.
• Pseudocode:
It is an implementation of an algorithm in form of annotations and informative text
written in plain English.
Steps to write pseudocode: 1. Arrange sequence of tasks and write
pseudocode accordingly.
2. Start with the statement of the pseudocode
which establishes main goal /aim
• Example:This program will allow the user to check whether the number is
even or odd.
In the main prompt
Print prompt “ Enter a number”
Take the number and divide by two
If result=0
print response “ Even”
If result>0
print response “odd”
end
• Algorithm for making tea:
Step-1: Boil water
Step-2: PutTea Powder in the kettle.
Step-3 : Pour boiled water in the kettle
Step-4:Wait for three minutes
Step-5 : Boil Milk
Step-6: Put boiled milk in a cup
Step-7: Add Sugar in the cup
Step-8: Empty the kettle in the cup
Step-9: Stirr the contents of cup with spoon
Flow chart
• Pictorial representation of algorithm is called Flowchart.
• In it’s simplest form, a flow chart consists of a series of symbols connected
by arrows to designate the flow.
BEGIN
BOILWATER
PUTTEA POWDERAND HOT
WATER IN KETTLE
WIAT FORTHREE MINUTES
AND BOIL MILK
PUT BOILED MILK IN A CUP
ADD SUGARTOTHE CUP
EMPTYTHE KETTLE INTOTHE
CUP
STIRRTHE CONTENTS OF CUP
WITH SPOON
END
Three Basic Operations
• Sequence – A series of steps that we perform one after another.
• Selection – Making a choice from multiple available options.
• Iteration – Performing repetitive tasks.
FLOW CHART AND ALGORITHM FORWORKING OF
ATM MACHINE
• Problem statement:With draw cash from ATM
• Algorithm:
Step - 1: Go to the ATM
Step – 2: Insert your card into the
machine
Step – 3: Enter the pin of card
Step – 4: Choose withdraw option
and enter the amount
to be withdrawn
Step – 5: Take the cash, slip and card
Decision making in flowcharts
• Problem Statement : Print what to do when
driving in a traffic signal
• Algorithm:
Step – 1: Read traffic signal
Step – 2 : If signal is GREEN the
set action as GO
Else
Set action as Stop.
Step – 3: Print Action.
Iteration in Flow charts
• Problem Statement: Print numbers
from 1-20.
• Algorithm:
Step – 1: Initialize X as 0.
Step – 2: Increment X by
1.
Step – 3: Print value in X.
Step – 4: If value of X is
less than 20 go
back to step 2
else exit .
Introduction to Computers
• 1. Computer Systems : A computer is a system made of two major
components : hardware and software .
• The computer hardware is the physical equipment.
• The software is collection of programs(instructions) that allow the hardware
to do it’s job.
Computer Hardware
• The hardware component of the computer system consists of five parts: input
devices, Central Processing Unit(CPU), primary storage, output devices and
auxiliary devices.
• The input devices includes keyboard , mouse , scanner, audio input unit etc.,
• The Central processing unit is responsible for executing instructions such as
arithmetic calculations, comparisons among data and movement of data inside
the system.
• Primary storage is also called as Main-Memory , is a place where programs and
data are stored temporarily during processing.
• The output device is usually a monitor or printer to show output.
• Auxiliary storage is also known as secondary storage , used for both input and
output. It is the place where programs and data are stored permanently.
Computer Software
• Computer Software is divided into two broad categories: system software and
application software.
• System software manages the computer resources. It provides the interface
between hardware and users .
• Application software is directly responsible for helping users to solve their
problems through applications.
• 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. These software products comprise of programs written
in low-level languages, which interact with the hardware at a very
basic level.
• System software serves as the interface between the hardware and
the end users.
• Some examples of system software are Operating System, Compilers,
Interpreter, Assemblers, etc.
• The operating system provides services such as user interface , file and
database access , interface to communication systems such as internet
protocols . Major role of tis software is to keep system operating in efficient
manner.
• System software provides utilities and other operating services. Like sort
programs and disk format programs.
• System development software include the language translators that
convert program into machine language for execution,debugging tools to
ensure that programs are error free .
• Application software: Application software products are designed to satisfy a
particular need of a particular environment. All software applications prepared in the
computer lab can come under the category of Application software.
• Application software may consist of a single program, such as Microsoft's notepad
for writing and editing a simple text. It may also consist of a collection of programs,
often called a software package, which work together to accomplish a task, such as
a spreadsheet package.
• Examples of Application software are the following −
Payroll Software
Student Record Software
Inventory Management Software
Income Tax Software
Railways Reservation Software
• General purpose software is purchased from a software developer and can be used for
more than one application and these include: word processors, database management
systems and computer aided design systems.
• Application specific software can be used only for it’s intended purpose .A general
ledger system used by accountants and a material requirements planning system used
by a manufacturing organizations are examples of application –specific software.
• The inner core is hardware, the user is represented by the outerlayer .
• To work with the system , the typical user uses some form of application software and
this application software in turn interacts with the operating systems.
• Installing, Running and Uninstalling Software:
• Installing is the process of setting up software to work with computer ,
Printer and other hardware components.
• To install software from a CD or DVD , insert program disc into the drive and
then computer copies all or part of the program from disc to computer’s
hard disk.
• Once the software is installed, you can run on instructing the computer ,it
loads the software which means copied form secondary storage to main
memory.
• When the software is no longer in use, it must be removed or uninstalled
that entails deleting all the files pertaining to the software.
Software Piracy : Software piracy is the intelligence or unauthorized
distribution or reproduction of software applications which is a copyright
infringement act.
Computing Environments:
Personal computing environment
Time Sharing Environment
Client/ Server environment
Distributed Computing
Personal Computing Environment
• In the personal computing environment, there is a single computer
system. All the system processes are available on the computer and
executed there. The different devices that constitute a personal
computing environment are laptops, mobiles, printers, computer
systems, scanners etc.
Time Sharing Computing Environment
• The time sharing computing environment allows multiple users to
share the system simultaneously. Each user is provided a time slice
and the processor switches rapidly among the users according to it.
Because of this, each user believes that they are the only ones using
the system.
Client Server Computing Environment
• In client server computing, the client requests a
resource and the server provides that resource.
A server may serve multiple clients at the same
time while a client is in contact with only one
server. Both the client and server usually
communicate via a computer network but
sometimes they may reside in the same system.
Distributed Computing Environment
• A distributed computing environment contains
multiple nodes that are physically separate but
linked together using the network. All the nodes
in this system communicate with each other and
handle processes in tandem. Each of these
nodes contains a small part of the distributed
operating system software.
Creating and running programs
• Executing a involves a series of steps: 1. Creating the program
2. Compiling the program
3. Linking the program with the
functions that are needed
from the library
4. Executing the program
What is a compilation?
• The compilation is a process of converting the source code into object code. It is done with
the help of the compiler.The compiler checks the source code for the syntactical or
structural errors, and if the source code is error-free, then it generates the object code.
• The compilation process can be divided into four steps, i.e., Pre-processing, Compiling,
Assembling, and Linking.
• The preprocessor takes the source code as an input, and it removes all the comments from
the source code. The preprocessor takes the preprocessor directive and interprets it.
• For example, if <stdio.h>, the directive is available in the program, then the preprocessor
interprets the directive and replace this directive with the content of the 'stdio.h' file.
• The following are the phases through which our program passes before being transformed into
an executable form:
Preprocessor
Compiler
Assembler
Linker
Preprocessor
• The source code is the code which is written in a text editor and the source code file is given an extension
".c".This source code is first passed to the preprocessor, and then the preprocessor expands this code.
After expanding the code, the expanded code is passed to the compiler.
Compiler
• The code which is expanded by the preprocessor is passed to the compiler.The compiler converts this code
into assembly code. Or we can say that the C compiler converts the pre-processed code into assembly
code.
Assembler
• The assembly code is converted into object code by using an assembler.The name of the
object file generated by the assembler is the same as the source file.The extension of the
object file in DOS is '.obj,' and in UNIX, the extension is 'o'. If the name of the source file
is 'hello.c', then the name of the object file would be 'hello.obj'.
Linker
• Mainly, all the programs written in C use library functions.These library functions
are pre-compiled, and the object code of these library files is stored with '.lib' (or
'.a') extension.The main working of the linker is to combine the object code of
library files with the object code of our program.
• The output of the linker is the executable file.The name of the executable file is the same
as the source file but differs only in their extensions.
Computer Number System
• When we type some letters or words, the computer translates them in
numbers as computers can understand only numbers. A computer can
understand the positional number system where there are only a few
symbols called digits and these symbols represent different values
depending on the position they occupy in the number.
• The value of each digit in a number can be determined using −
The digit
The position of the digit in the number
The base of the number system (where the base is defined as the
total number of digits available in the number system)
• Decimal Number System:
Decimal number system has base 10 as it uses 10 digits from 0 to 9. In decimal
number system, the successive positions to the left of the decimal point represent units,
tens, hundreds, thousands, and so on.
Each position represents a specific power of the base (10). For example, the decimal
number 1234 consists of the digit 4 in the units position, 3 in the tens position, 2 in the
hundreds position, and 1 in the thousands position . It’s value can be written as:
Computer Memory
• It is useful to know how to store
information on a computer because this
will allow us to reason about the amount
of space that will be required to store a
data set, which in turn will allow us to
determine what software or hardware
we will need to be able to work with a
data set, and to decide upon an
appropriate storage format. In order to
access a data set correctly, it can also be
useful to know how data has been
stored; for example, there are many
ways that a simple number could be
stored.
Bit , Byte andWord
• The surface of a CD magnified many times to show the pits in the surface that
encode information.
• The most fundamental unit of computer memory is the bit. A bit can be a tiny
magnetic region on a hard disk, a tiny dent in the reflective material on a CD
or DVD, or a tiny transistor on a memory stick. Whatever the physical
implementation, the important thing to know about a bit is that, like a switch,
it can only take one of two values: it is either “on” or “off”.
• A collection of 8 bits is called a byte and (on the majority of computers today) a collection of
4 bytes, or 32 bits, is called a word.
• Each individual data value in a data set is usually stored using one or more bytes of memory,
but at the lowest level, any data stored on a computer is just a large collection of bits.
• At the lowest level, a data set is just a series of zeroes and ones.
• The number of bytes and words used for an individual data value will vary depending on the
storage format, the operating system, and even the computer hardware, but in many cases, a
single letter or character of text takes up one byte and an integer, or whole number, takes up
one word. A real or decimal number takes up one or two words depending on how it is stored.
Storing Integers
• Integers are whole numbers which will be stored in computer
using 4 bytes(32 bit ) of memory.
• For example binary equivalent of 65 is (1000001)2
• The Most Significant Bit(MSB) is used to indicate whether the
number is positive or negative.
• For positive integers MSB will be ‘0’ and for negative integers
MSB will be ‘1’.
• In our case 65 is positive so the so MSB will be o
• The binary equivalent of 65 will be stored as :
Storing Real numbers
• To store a floating point number,4-byte(32-bit) memory will be allocated in the computer
memory.
 1 bit for sign
 8 bit for exponent part
 23 bit for significant part
• Procedure:
 Floating number will be converted into binary number.
 Make the converted binary number into normalize form
 Add bias to the exponent
Formula to calculate bias value:
bias n =2n-1 -1
• Example: 1. We need to store 10.75
2. Converting 10.75 into binary gives (1010.11)2
3. For floating point numbers we always normalize it like
1.significant bit * 2 exponent
4. So 1010.11 will be normalized as 1.01011*2 3 since we have
shifted 3 bits to left side.
5. Whether the number is positive or negative, we add bias value
to the exponent to reduce the complexity.
6. In this case we have allocated 8 bits for exponent so n will be 8
=> 27 -1 = 127
So the normalized exponent value will be :
Actual exponent + Bias value = 3+127 = 130.
7. Binary form of 130 is (10000010) 2
• To store double, computer will allocate 8 byte (64
bit) memory.
1 bit for sign,
11 bit for exponent,
52 bit for significant.
• only difference between double and float
representation is the bias value.
• Here we use 11 bit for exponent.So bias value will
be 211 - 1 - 1 i.e 210 - 1 which is 1023.
Storing Characters
• When we try to store character value
in computer, it will not store
character directly rather it will store
correspondingASCII value
• For example, if we want to store char ‘A’ in computer, the
corresponding ASCII value will be stored in computer.
• ASCII value for capital A is 65.
• To store character value, computer will allocate 1 byte (8 bit) memory.
• 65 will converted into binary form which is (1000001) 2. Because
computer knows only binary number system.
• Then 1000001 will be stored in 8-bit memory.
Introduction to ‘C’ Language
• Basics of C: C is a structured programming language. It is considered a
high-level language because it allows the programmer to concentrate on
the problem at hand and no worry about the machine that the program will
be using.
• It is fromALGOL , the first language to use a block structure.
• Dennis Ritchie developed C in 1972
Structure of a C Program
• Every C program is made of one or more functions .
• Every C program comprises of 5 components: 1. Preprocessor Directives
2. Global Declarations
3. Main
a. Local Declarations
b. Statements
4. Other Functions as required.
• Preprocessor Commands:
The preprocessor commands come at the beginning of the program.All the
preprocessor commands start with a pound sign (#).,followed by keyword
include and the name of the library file included in pointed brackets(<>) which is
one of the rules of C known as “syntax”.
 The preprocessor command tells the compiler to include the standard
input/output library file(to print the message at the terminal) in the program.
Example: #include<stdio.h>
stdio.h is name of header file that includes “standard input/output
functions.
• Main:
The executable part of your program begins with the function “ main “ followed
by opening and closing paranthesis “()”.
int main() indicates that the code in function main returns integer
value to the operating system.
void main() indicates that the code in the main block does not
return any value to the operating system.
• Comments and Block comments:
A single comment line describes the work of code or particular statement in the
program.
Block comments are a lengthier description of block of code.
The greeting program
Identifiers in C
• Identifiers allow us to name the data and other objects in the program.
• Each identified object in the computer is stored at a unique address.
• Different programming languages use different syntactical rules to form
identifiers.
• To define a identifier in C we need to use either capital or small letters from
a-z and the digits ,underscores(_) .
• The first character of the identifier cannot be a digit.
• The name of identifier cannot be keywords / reserved words .
• C is a case-sensitive language.
Data types in C
• A type defines a set of values and a set of operations that can be applied on
those values .
• C language has defined set of types that can be divided into four general
categories.
• Data types in C are of three major categories.
1. Primitive data types
2. Derived data types
3. User defined data types.
1.Primitive data types:
Character data type: Character is any value that can be represented in the computer’s alphabet.To declare
a character data type the syntax is : char x;
 Most of the computer systems use 1 byte to store the character data type .
Integer data type: An integer data type is a number without fraction part.
C supports four different sizes of the integer data type : short int, int , long int, long long int.
Sizeof(short)<sizeof(int)<sizeof(long)<sizeof (long long)
Each integer can be a signed or an unsigned integer.
int x;
Floating point data type: All numeric data type items with fractional part belong to float type.
Keyword float is used to declare the variables of float type.
float x;
A variable of float type requires 4 bytes and the range of values can be stored in it
is 3.48-38 to 3.48+38.
Double and long double are two datatypes used to store numeric data with
lengthy fracitional point
Sizeof(float)<sizeof(double)<sizeof(long double).
Constants in C
• C Constants is the most fundamental and essential part of the C
programming language. Constants in C are the fixed values that are
used in a program, and its value remains the same during the entire
execution of the program.
• Constants are also called literals.
• Constants can be any of the data types.
• It is considered best practice to define constants using only upper-
case names.
• Constants are categorized
into two basic types and each
of these has its subtypes or
categories.
Numeric Constants
Integer Constants:
• An integer literal can be a decimal, octal, or hexadecimal constant. A
prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 for octal,
and nothing for decimal.
• An integer literal can also have a suffix that is a combination of U and
L, for unsigned and long, respectively. The suffix can be uppercase or
lowercase and can be in any order.
• Floating Point Literals:
• A floating-point literal has an integer part, a decimal point, a fractional
part, and an exponent part. You can represent floating point literals
either in decimal form or exponential form.
• While representing decimal form, you must include the decimal point,
the exponent, or both; and while representing exponential form, you
must include the integer part, the fractional part, or both. The signed
exponent is introduced by e or E.
Character Constants
Single Character Constant:
• Character literals are enclosed in single quotes, e.g., 'x' can be stored
in a simple variable of char type.
• A character literal can be a plain character (e.g., 'x'), an escape
sequence (e.g., 't'), or a universal character (e.g., 'u02C0').
• There are certain characters in C that represent special meaning when
preceded by a backslash for example, newline (n) or tab (t).
• String Character Constant: String literals or constants are enclosed in
double quotes "". A string contains characters that are similar to
character literals: plain characters, escape sequences, and universal
characters.
• You can break a long line into multiple lines using string literals and
separating them using white spaces.
Defining Constants:
• We can define constants in two different ways:
(i)Using #define pre processor.
(ii)Using “const” keyword.
We declare a variable as constant before main using #define pre processor.
Syntax: #define identifier value
We can declare a variable as constant inside main using keyword “const”
Syntax: const type variablename=value;
C -Variables
• A variable is nothing but a name given to a storage area that our programs
can manipulate. Each variable in C has a specific type, which determines the
size and layout of the variable's memory; the range of values that can be
stored within that memory; and the set of operations that can be applied to
the variable.
• The name of a variable can be composed of letters, digits, and the
underscore character. It must begin with either a letter or an underscore.
Upper and lowercase letters are distinct because C is case-sensitive.
Sr.No. Type & Description
1 char
Typically a single octet(one byte). It is an integer type.
2 int
The most natural size of integer for the machine.
3 float
A single-precision floating point value.
4 double
A double-precision floating point value.
5 void
Represents the absence of type.
Variable Definition in C
• Variable definition tells the compiler where and how much storage to create
for the variable. A variable definition specifies a data type and contains a list
of one or more variables of that type
Example: int i,j,k;
char a,b,c;
Lvalues and Rvalues in C
• There are two kinds of expressions in C −
• lvalue − Expressions that refer to a memory location are called "lvalue"
expressions. An lvalue may appear as either the left-hand or right-hand side
of an assignment.
• rvalue −The term rvalue refers to a data value that is stored at some
address in memory.An rvalue is an expression that cannot have a value
assigned to it which means an rvalue may appear on the right-hand side but
not on the left-hand side of an assignment.
Input and output
• Input, means to feed some data into a program.
• An input can be given in the form of a file or from the command line.
• C programming provides a set of built-in functions to read the given input and
feed it to the program as per requirement.
• Output, it means to display some data on screen, printer, or in any file.
• C programming provides a set of built-in functions to output the data on the
computer screen as well as to save it in text or binary files.
• The Standard Files
• C programming treats all the devices as files. So devices such as the
display are addressed in the same way as files and the following three
files are automatically opened when a program executes to provide
access to the keyboard and screen.
Output:
• A valid C program must contain the ,main() function .The code execution
starts from the main()/ function .
• The printf() is a library function to send formatted output to the screen.
• The function prints the string inside the double quotes.
• To use printf() we need to include stdio.h headerfile in our program.
Input:
• In C programming scanf() is one of the commonly used function to take
input from the user.
• The scanf() funcition reads the formatted input
Format specifiers for I/O
TYPE CONVERSION
IMPLICIT TYPE CONVERSION:
Also known as ‘automatic type conversion’.
Done by the compiler on its own, without any external trigger from the user.
Generally takes place when in an expression more than one data type is present. In
such condition type conversion (type promotion) takes place to avoid lose of data.
All the data types of the variables are upgraded to the data type of the variable with
largest data type.
It is possible for implicit conversions to lose information, signs can be lost (when
signed is implicitly converted to unsigned), and overflow can occur (when long long is
implicitly converted to float).
• Important Points about Implicit Conversions
• Implicit type of type conversion is also called as standard type
conversion. We do not require any keyword or special statements in
implicit type casting.
• Converting from smaller data type into larger data type is also called
as type promotion.
• The implicit type conversion always happens with the compatible data
types.
• We cannot perform implicit type casting on the data types which are
not compatible with each other such as:
1.Converting float to an int will truncate the fraction part hence losing
the meaning of the value.
2.Converting double to float will round up the digits.
3.Converting long int to int will cause dropping of excess high order
EXPLICITTYPE CONVERSION
• This process is also called type casting and it is user defined. Here the user
can type cast the result to make it of a particular data type.
• In implicit type conversion, the data type is converted
automatically. There are some scenarios in which we may have to
force type conversion. Suppose we have a variable div that stores
the division of two operands which are declared as an int data
type.
• In this case, after the division performed on variables var1 and var2 the
result stored in the variable "result" will be in an integer format.
Whenever this happens, the value stored in the variable "result" loses
its meaning because it does not consider the fraction part which is
normally obtained in the division of two numbers.
• To force the type conversion in such situations, we use explicit type
casting.
• It requires a type casting operator. The general syntax for type casting
operations is as follows: (type-name)expression
• It requires a type casting operator. The general syntax for type
casting operations is as follows:
(type-name)expression
Here,
• The type name is the standard 'C' language data type.
• An expression can be a constant, a variable or an actual
expression.
c programming 1-1.pptx

More Related Content

Similar to c programming 1-1.pptx

Week 01.pdf
Week 01.pdfWeek 01.pdf
Week 01.pdf
ChuadaryUsamaGujjar
 
lec 1.pptx
lec 1.pptxlec 1.pptx
lec 1.pptx
AhsanAli64749
 
Bba i-introduction to computer-u-2- application and system software
Bba  i-introduction to computer-u-2- application and system softwareBba  i-introduction to computer-u-2- application and system software
Bba i-introduction to computer-u-2- application and system software
Rai University
 
OOSE UNIT-1.pdf
OOSE UNIT-1.pdfOOSE UNIT-1.pdf
OOSE UNIT-1.pdf
KarumuriJayasri
 
Mca i-fundamental of computer-u-2- application and system software
Mca  i-fundamental of  computer-u-2- application and system softwareMca  i-fundamental of  computer-u-2- application and system software
Mca i-fundamental of computer-u-2- application and system software
Rai University
 
Introductoin of computer hardware and software
Introductoin of computer hardware and softwareIntroductoin of computer hardware and software
Introductoin of computer hardware and software
Uttara University
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
Sukhendra Singh
 
Bca i-fundamental of computer-u-2- application and system software
Bca  i-fundamental of  computer-u-2- application and system softwareBca  i-fundamental of  computer-u-2- application and system software
Bca i-fundamental of computer-u-2- application and system software
Rai University
 
Programming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxProgramming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptx
TeddyDaka
 
Topic -Anatomy of Computer.pptx
Topic -Anatomy  of Computer.pptxTopic -Anatomy  of Computer.pptx
Topic -Anatomy of Computer.pptx
PragatiKachhi1
 
Interaction With Computers FIT
Interaction With Computers FITInteraction With Computers FIT
Interaction With Computers FIT
Raj vardhan
 
Lecture-3-02112021-013630pm.pdf
Lecture-3-02112021-013630pm.pdfLecture-3-02112021-013630pm.pdf
Lecture-3-02112021-013630pm.pdf
MuhammadFaizan184425
 
Bsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system softwareBsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system software
Rai University
 
Mba i-ifm-u-2-computer software
Mba i-ifm-u-2-computer softwareMba i-ifm-u-2-computer software
Mba i-ifm-u-2-computer software
Rai University
 
Software Engineering _ Introduction
Software Engineering _ IntroductionSoftware Engineering _ Introduction
Software Engineering _ Introduction
ThenmozhiK5
 
A level-computing-9691-paper-1-notes
A level-computing-9691-paper-1-notesA level-computing-9691-paper-1-notes
A level-computing-9691-paper-1-notes
huzyrah
 
Introduction to Computer Softwares
Introduction to Computer SoftwaresIntroduction to Computer Softwares
Introduction to Computer Softwares
Naresh Dubey
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
DeepalShah123
 
Computer Organisation unit 1 basics of computer Organisation
Computer Organisation unit 1 basics of computer OrganisationComputer Organisation unit 1 basics of computer Organisation
Computer Organisation unit 1 basics of computer Organisation
luckyanirudhsai
 
UNIT-111.pptx
UNIT-111.pptxUNIT-111.pptx
UNIT-111.pptx
JALLAANITHAREDDY
 

Similar to c programming 1-1.pptx (20)

Week 01.pdf
Week 01.pdfWeek 01.pdf
Week 01.pdf
 
lec 1.pptx
lec 1.pptxlec 1.pptx
lec 1.pptx
 
Bba i-introduction to computer-u-2- application and system software
Bba  i-introduction to computer-u-2- application and system softwareBba  i-introduction to computer-u-2- application and system software
Bba i-introduction to computer-u-2- application and system software
 
OOSE UNIT-1.pdf
OOSE UNIT-1.pdfOOSE UNIT-1.pdf
OOSE UNIT-1.pdf
 
Mca i-fundamental of computer-u-2- application and system software
Mca  i-fundamental of  computer-u-2- application and system softwareMca  i-fundamental of  computer-u-2- application and system software
Mca i-fundamental of computer-u-2- application and system software
 
Introductoin of computer hardware and software
Introductoin of computer hardware and softwareIntroductoin of computer hardware and software
Introductoin of computer hardware and software
 
Programming for Problem Solving
Programming for Problem SolvingProgramming for Problem Solving
Programming for Problem Solving
 
Bca i-fundamental of computer-u-2- application and system software
Bca  i-fundamental of  computer-u-2- application and system softwareBca  i-fundamental of  computer-u-2- application and system software
Bca i-fundamental of computer-u-2- application and system software
 
Programming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptxProgramming requirements for beginning in software engineering.pptx
Programming requirements for beginning in software engineering.pptx
 
Topic -Anatomy of Computer.pptx
Topic -Anatomy  of Computer.pptxTopic -Anatomy  of Computer.pptx
Topic -Anatomy of Computer.pptx
 
Interaction With Computers FIT
Interaction With Computers FITInteraction With Computers FIT
Interaction With Computers FIT
 
Lecture-3-02112021-013630pm.pdf
Lecture-3-02112021-013630pm.pdfLecture-3-02112021-013630pm.pdf
Lecture-3-02112021-013630pm.pdf
 
Bsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system softwareBsc cs 1 fit u-2 application and system software
Bsc cs 1 fit u-2 application and system software
 
Mba i-ifm-u-2-computer software
Mba i-ifm-u-2-computer softwareMba i-ifm-u-2-computer software
Mba i-ifm-u-2-computer software
 
Software Engineering _ Introduction
Software Engineering _ IntroductionSoftware Engineering _ Introduction
Software Engineering _ Introduction
 
A level-computing-9691-paper-1-notes
A level-computing-9691-paper-1-notesA level-computing-9691-paper-1-notes
A level-computing-9691-paper-1-notes
 
Introduction to Computer Softwares
Introduction to Computer SoftwaresIntroduction to Computer Softwares
Introduction to Computer Softwares
 
Unit 1.pptx
Unit 1.pptxUnit 1.pptx
Unit 1.pptx
 
Computer Organisation unit 1 basics of computer Organisation
Computer Organisation unit 1 basics of computer OrganisationComputer Organisation unit 1 basics of computer Organisation
Computer Organisation unit 1 basics of computer Organisation
 
UNIT-111.pptx
UNIT-111.pptxUNIT-111.pptx
UNIT-111.pptx
 

Recently uploaded

Data Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdfData Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdf
Kamal Acharya
 
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Dr.Costas Sachpazis
 
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
Ak47
 
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdfSri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Balvir Singh
 
Intuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sdeIntuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sde
ShivangMishra54
 
Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Call Girls Madurai 8824825030 Escort In Madurai service 24X7Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Poonam Singh
 
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
dABGO KI CITy kUSHINAGAR Ak47
 
BBOC407 Module 1.pptx Biology for Engineers
BBOC407  Module 1.pptx Biology for EngineersBBOC407  Module 1.pptx Biology for Engineers
BBOC407 Module 1.pptx Biology for Engineers
sathishkumars808912
 
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
nainakaoornoida
 
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdfSELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
Pallavi Sharma
 
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptxMODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
NaveenNaveen726446
 
Covid Management System Project Report.pdf
Covid Management System Project Report.pdfCovid Management System Project Report.pdf
Covid Management System Project Report.pdf
Kamal Acharya
 
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
sexytaniya455
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Tsuyoshi Horigome
 
🔥 Hyderabad Call Girls  👉 9352988975 👫 High Profile Call Girls Whatsapp Numbe...
🔥 Hyderabad Call Girls  👉 9352988975 👫 High Profile Call Girls Whatsapp Numbe...🔥 Hyderabad Call Girls  👉 9352988975 👫 High Profile Call Girls Whatsapp Numbe...
🔥 Hyderabad Call Girls  👉 9352988975 👫 High Profile Call Girls Whatsapp Numbe...
aarusi sexy model
 
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 MinutesCall Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
kamka4105
 
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC ConduitThe Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
Guangdong Ctube Industry Co., Ltd.
 
SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )
Tsuyoshi Horigome
 
Cricket management system ptoject report.pdf
Cricket management system ptoject report.pdfCricket management system ptoject report.pdf
Cricket management system ptoject report.pdf
Kamal Acharya
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
DharmaBanothu
 

Recently uploaded (20)

Data Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdfData Communication and Computer Networks Management System Project Report.pdf
Data Communication and Computer Networks Management System Project Report.pdf
 
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
Sachpazis_Consolidation Settlement Calculation Program-The Python Code and th...
 
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
College Call Girls Kolkata 🔥 7014168258 🔥 Real Fun With Sexual Girl Available...
 
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdfSri Guru Hargobind Ji - Bandi Chor Guru.pdf
Sri Guru Hargobind Ji - Bandi Chor Guru.pdf
 
Intuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sdeIntuit CRAFT demonstration presentation for sde
Intuit CRAFT demonstration presentation for sde
 
Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Call Girls Madurai 8824825030 Escort In Madurai service 24X7Call Girls Madurai 8824825030 Escort In Madurai service 24X7
Call Girls Madurai 8824825030 Escort In Madurai service 24X7
 
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
High Profile Call Girls Ahmedabad 🔥 7737669865 🔥 Real Fun With Sexual Girl Av...
 
BBOC407 Module 1.pptx Biology for Engineers
BBOC407  Module 1.pptx Biology for EngineersBBOC407  Module 1.pptx Biology for Engineers
BBOC407 Module 1.pptx Biology for Engineers
 
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
❣Independent Call Girls Chennai 💯Call Us 🔝 7737669865 🔝💃Independent Chennai E...
 
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdfSELENIUM CONF -PALLAVI SHARMA - 2024.pdf
SELENIUM CONF -PALLAVI SHARMA - 2024.pdf
 
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptxMODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
MODULE 5 BIOLOGY FOR ENGINEERS TRENDS IN BIO ENGINEERING.pptx
 
Covid Management System Project Report.pdf
Covid Management System Project Report.pdfCovid Management System Project Report.pdf
Covid Management System Project Report.pdf
 
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
Call Girls Nagpur 8824825030 Escort In Nagpur service 24X7
 
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
Update 40 models( Solar Cell ) in SPICE PARK(JUL2024)
 
🔥 Hyderabad Call Girls  👉 9352988975 👫 High Profile Call Girls Whatsapp Numbe...
🔥 Hyderabad Call Girls  👉 9352988975 👫 High Profile Call Girls Whatsapp Numbe...🔥 Hyderabad Call Girls  👉 9352988975 👫 High Profile Call Girls Whatsapp Numbe...
🔥 Hyderabad Call Girls  👉 9352988975 👫 High Profile Call Girls Whatsapp Numbe...
 
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 MinutesCall Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
Call Girls In Tiruppur 👯‍♀️ 7339748667 🔥 Free Home Delivery Within 30 Minutes
 
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC ConduitThe Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
The Differences between Schedule 40 PVC Conduit Pipe and Schedule 80 PVC Conduit
 
SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )SPICE PARK JUL2024 ( 6,866 SPICE Models )
SPICE PARK JUL2024 ( 6,866 SPICE Models )
 
Cricket management system ptoject report.pdf
Cricket management system ptoject report.pdfCricket management system ptoject report.pdf
Cricket management system ptoject report.pdf
 
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
An In-Depth Exploration of Natural Language Processing: Evolution, Applicatio...
 

c programming 1-1.pptx

  • 2. INDEX • Algorithm and Flow-chart • Introduction to Computers • Creating and Running Programs • Computer Numbering Systems • Storing Integers • Storing Real-numbers • Introduction to C- Language: • Background • C-Programs • Identifiers • Variables • Type Constants • Input/Output • Programming Examples • Structure of C • Type conversion Statements • Sample Programs
  • 3. Algorithms /Pseudocode • Algorithm is the step-by-step method of performing any task. • When we breakup a big task into smaller steps, what we actually do is to create an Algorithm. • Each step can be called an Instruction. • In technical terms, an algorithm is an organized logical sequence of actions or approach towards a particular problem.
  • 4. • Pseudocode: It is an implementation of an algorithm in form of annotations and informative text written in plain English. Steps to write pseudocode: 1. Arrange sequence of tasks and write pseudocode accordingly. 2. Start with the statement of the pseudocode which establishes main goal /aim
  • 5. • Example:This program will allow the user to check whether the number is even or odd. In the main prompt Print prompt “ Enter a number” Take the number and divide by two If result=0 print response “ Even” If result>0 print response “odd” end
  • 6. • Algorithm for making tea: Step-1: Boil water Step-2: PutTea Powder in the kettle. Step-3 : Pour boiled water in the kettle Step-4:Wait for three minutes Step-5 : Boil Milk Step-6: Put boiled milk in a cup Step-7: Add Sugar in the cup Step-8: Empty the kettle in the cup Step-9: Stirr the contents of cup with spoon
  • 7. Flow chart • Pictorial representation of algorithm is called Flowchart. • In it’s simplest form, a flow chart consists of a series of symbols connected by arrows to designate the flow.
  • 8. BEGIN BOILWATER PUTTEA POWDERAND HOT WATER IN KETTLE WIAT FORTHREE MINUTES AND BOIL MILK PUT BOILED MILK IN A CUP ADD SUGARTOTHE CUP EMPTYTHE KETTLE INTOTHE CUP STIRRTHE CONTENTS OF CUP WITH SPOON END
  • 9. Three Basic Operations • Sequence – A series of steps that we perform one after another. • Selection – Making a choice from multiple available options. • Iteration – Performing repetitive tasks.
  • 10.
  • 11. FLOW CHART AND ALGORITHM FORWORKING OF ATM MACHINE • Problem statement:With draw cash from ATM • Algorithm: Step - 1: Go to the ATM Step – 2: Insert your card into the machine Step – 3: Enter the pin of card Step – 4: Choose withdraw option and enter the amount to be withdrawn Step – 5: Take the cash, slip and card
  • 12. Decision making in flowcharts • Problem Statement : Print what to do when driving in a traffic signal • Algorithm: Step – 1: Read traffic signal Step – 2 : If signal is GREEN the set action as GO Else Set action as Stop. Step – 3: Print Action.
  • 13. Iteration in Flow charts • Problem Statement: Print numbers from 1-20. • Algorithm: Step – 1: Initialize X as 0. Step – 2: Increment X by 1. Step – 3: Print value in X. Step – 4: If value of X is less than 20 go back to step 2 else exit .
  • 14. Introduction to Computers • 1. Computer Systems : A computer is a system made of two major components : hardware and software . • The computer hardware is the physical equipment. • The software is collection of programs(instructions) that allow the hardware to do it’s job.
  • 15. Computer Hardware • The hardware component of the computer system consists of five parts: input devices, Central Processing Unit(CPU), primary storage, output devices and auxiliary devices. • The input devices includes keyboard , mouse , scanner, audio input unit etc., • The Central processing unit is responsible for executing instructions such as arithmetic calculations, comparisons among data and movement of data inside the system. • Primary storage is also called as Main-Memory , is a place where programs and data are stored temporarily during processing. • The output device is usually a monitor or printer to show output. • Auxiliary storage is also known as secondary storage , used for both input and output. It is the place where programs and data are stored permanently.
  • 16. Computer Software • Computer Software is divided into two broad categories: system software and application software. • System software manages the computer resources. It provides the interface between hardware and users . • Application software is directly responsible for helping users to solve their problems through applications.
  • 17. • 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. These software products comprise of programs written in low-level languages, which interact with the hardware at a very basic level. • System software serves as the interface between the hardware and the end users. • Some examples of system software are Operating System, Compilers, Interpreter, Assemblers, etc.
  • 18. • The operating system provides services such as user interface , file and database access , interface to communication systems such as internet protocols . Major role of tis software is to keep system operating in efficient manner. • System software provides utilities and other operating services. Like sort programs and disk format programs. • System development software include the language translators that convert program into machine language for execution,debugging tools to ensure that programs are error free .
  • 19. • Application software: Application software products are designed to satisfy a particular need of a particular environment. All software applications prepared in the computer lab can come under the category of Application software. • Application software may consist of a single program, such as Microsoft's notepad for writing and editing a simple text. It may also consist of a collection of programs, often called a software package, which work together to accomplish a task, such as a spreadsheet package. • Examples of Application software are the following − Payroll Software Student Record Software Inventory Management Software Income Tax Software Railways Reservation Software
  • 20. • General purpose software is purchased from a software developer and can be used for more than one application and these include: word processors, database management systems and computer aided design systems. • Application specific software can be used only for it’s intended purpose .A general ledger system used by accountants and a material requirements planning system used by a manufacturing organizations are examples of application –specific software. • The inner core is hardware, the user is represented by the outerlayer . • To work with the system , the typical user uses some form of application software and this application software in turn interacts with the operating systems.
  • 21. • Installing, Running and Uninstalling Software: • Installing is the process of setting up software to work with computer , Printer and other hardware components. • To install software from a CD or DVD , insert program disc into the drive and then computer copies all or part of the program from disc to computer’s hard disk. • Once the software is installed, you can run on instructing the computer ,it loads the software which means copied form secondary storage to main memory. • When the software is no longer in use, it must be removed or uninstalled that entails deleting all the files pertaining to the software.
  • 22. Software Piracy : Software piracy is the intelligence or unauthorized distribution or reproduction of software applications which is a copyright infringement act. Computing Environments: Personal computing environment Time Sharing Environment Client/ Server environment Distributed Computing
  • 23. Personal Computing Environment • In the personal computing environment, there is a single computer system. All the system processes are available on the computer and executed there. The different devices that constitute a personal computing environment are laptops, mobiles, printers, computer systems, scanners etc. Time Sharing Computing Environment • The time sharing computing environment allows multiple users to share the system simultaneously. Each user is provided a time slice and the processor switches rapidly among the users according to it. Because of this, each user believes that they are the only ones using the system.
  • 24.
  • 25. Client Server Computing Environment • In client server computing, the client requests a resource and the server provides that resource. A server may serve multiple clients at the same time while a client is in contact with only one server. Both the client and server usually communicate via a computer network but sometimes they may reside in the same system. Distributed Computing Environment • A distributed computing environment contains multiple nodes that are physically separate but linked together using the network. All the nodes in this system communicate with each other and handle processes in tandem. Each of these nodes contains a small part of the distributed operating system software.
  • 26. Creating and running programs • Executing a involves a series of steps: 1. Creating the program 2. Compiling the program 3. Linking the program with the functions that are needed from the library 4. Executing the program
  • 27.
  • 28. What is a compilation? • The compilation is a process of converting the source code into object code. It is done with the help of the compiler.The compiler checks the source code for the syntactical or structural errors, and if the source code is error-free, then it generates the object code. • The compilation process can be divided into four steps, i.e., Pre-processing, Compiling, Assembling, and Linking. • The preprocessor takes the source code as an input, and it removes all the comments from the source code. The preprocessor takes the preprocessor directive and interprets it. • For example, if <stdio.h>, the directive is available in the program, then the preprocessor interprets the directive and replace this directive with the content of the 'stdio.h' file.
  • 29. • The following are the phases through which our program passes before being transformed into an executable form: Preprocessor Compiler Assembler Linker Preprocessor • The source code is the code which is written in a text editor and the source code file is given an extension ".c".This source code is first passed to the preprocessor, and then the preprocessor expands this code. After expanding the code, the expanded code is passed to the compiler. Compiler • The code which is expanded by the preprocessor is passed to the compiler.The compiler converts this code into assembly code. Or we can say that the C compiler converts the pre-processed code into assembly code.
  • 30. Assembler • The assembly code is converted into object code by using an assembler.The name of the object file generated by the assembler is the same as the source file.The extension of the object file in DOS is '.obj,' and in UNIX, the extension is 'o'. If the name of the source file is 'hello.c', then the name of the object file would be 'hello.obj'. Linker • Mainly, all the programs written in C use library functions.These library functions are pre-compiled, and the object code of these library files is stored with '.lib' (or '.a') extension.The main working of the linker is to combine the object code of library files with the object code of our program. • The output of the linker is the executable file.The name of the executable file is the same as the source file but differs only in their extensions.
  • 31.
  • 32. Computer Number System • When we type some letters or words, the computer translates them in numbers as computers can understand only numbers. A computer can understand the positional number system where there are only a few symbols called digits and these symbols represent different values depending on the position they occupy in the number. • The value of each digit in a number can be determined using − The digit The position of the digit in the number The base of the number system (where the base is defined as the total number of digits available in the number system)
  • 33. • Decimal Number System: Decimal number system has base 10 as it uses 10 digits from 0 to 9. In decimal number system, the successive positions to the left of the decimal point represent units, tens, hundreds, thousands, and so on. Each position represents a specific power of the base (10). For example, the decimal number 1234 consists of the digit 4 in the units position, 3 in the tens position, 2 in the hundreds position, and 1 in the thousands position . It’s value can be written as:
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39. Computer Memory • It is useful to know how to store information on a computer because this will allow us to reason about the amount of space that will be required to store a data set, which in turn will allow us to determine what software or hardware we will need to be able to work with a data set, and to decide upon an appropriate storage format. In order to access a data set correctly, it can also be useful to know how data has been stored; for example, there are many ways that a simple number could be stored.
  • 40. Bit , Byte andWord • The surface of a CD magnified many times to show the pits in the surface that encode information. • The most fundamental unit of computer memory is the bit. A bit can be a tiny magnetic region on a hard disk, a tiny dent in the reflective material on a CD or DVD, or a tiny transistor on a memory stick. Whatever the physical implementation, the important thing to know about a bit is that, like a switch, it can only take one of two values: it is either “on” or “off”.
  • 41. • A collection of 8 bits is called a byte and (on the majority of computers today) a collection of 4 bytes, or 32 bits, is called a word. • Each individual data value in a data set is usually stored using one or more bytes of memory, but at the lowest level, any data stored on a computer is just a large collection of bits. • At the lowest level, a data set is just a series of zeroes and ones. • The number of bytes and words used for an individual data value will vary depending on the storage format, the operating system, and even the computer hardware, but in many cases, a single letter or character of text takes up one byte and an integer, or whole number, takes up one word. A real or decimal number takes up one or two words depending on how it is stored.
  • 42. Storing Integers • Integers are whole numbers which will be stored in computer using 4 bytes(32 bit ) of memory. • For example binary equivalent of 65 is (1000001)2 • The Most Significant Bit(MSB) is used to indicate whether the number is positive or negative. • For positive integers MSB will be ‘0’ and for negative integers MSB will be ‘1’. • In our case 65 is positive so the so MSB will be o • The binary equivalent of 65 will be stored as :
  • 43. Storing Real numbers • To store a floating point number,4-byte(32-bit) memory will be allocated in the computer memory.  1 bit for sign  8 bit for exponent part  23 bit for significant part
  • 44. • Procedure:  Floating number will be converted into binary number.  Make the converted binary number into normalize form  Add bias to the exponent Formula to calculate bias value: bias n =2n-1 -1
  • 45. • Example: 1. We need to store 10.75 2. Converting 10.75 into binary gives (1010.11)2 3. For floating point numbers we always normalize it like 1.significant bit * 2 exponent 4. So 1010.11 will be normalized as 1.01011*2 3 since we have shifted 3 bits to left side. 5. Whether the number is positive or negative, we add bias value to the exponent to reduce the complexity. 6. In this case we have allocated 8 bits for exponent so n will be 8 => 27 -1 = 127 So the normalized exponent value will be : Actual exponent + Bias value = 3+127 = 130. 7. Binary form of 130 is (10000010) 2
  • 46. • To store double, computer will allocate 8 byte (64 bit) memory. 1 bit for sign, 11 bit for exponent, 52 bit for significant. • only difference between double and float representation is the bias value. • Here we use 11 bit for exponent.So bias value will be 211 - 1 - 1 i.e 210 - 1 which is 1023.
  • 47. Storing Characters • When we try to store character value in computer, it will not store character directly rather it will store correspondingASCII value
  • 48. • For example, if we want to store char ‘A’ in computer, the corresponding ASCII value will be stored in computer. • ASCII value for capital A is 65. • To store character value, computer will allocate 1 byte (8 bit) memory. • 65 will converted into binary form which is (1000001) 2. Because computer knows only binary number system. • Then 1000001 will be stored in 8-bit memory.
  • 49. Introduction to ‘C’ Language • Basics of C: C is a structured programming language. It is considered a high-level language because it allows the programmer to concentrate on the problem at hand and no worry about the machine that the program will be using. • It is fromALGOL , the first language to use a block structure. • Dennis Ritchie developed C in 1972
  • 50. Structure of a C Program • Every C program is made of one or more functions . • Every C program comprises of 5 components: 1. Preprocessor Directives 2. Global Declarations 3. Main a. Local Declarations b. Statements 4. Other Functions as required.
  • 51. • Preprocessor Commands: The preprocessor commands come at the beginning of the program.All the preprocessor commands start with a pound sign (#).,followed by keyword include and the name of the library file included in pointed brackets(<>) which is one of the rules of C known as “syntax”.  The preprocessor command tells the compiler to include the standard input/output library file(to print the message at the terminal) in the program. Example: #include<stdio.h> stdio.h is name of header file that includes “standard input/output functions.
  • 52.
  • 53. • Main: The executable part of your program begins with the function “ main “ followed by opening and closing paranthesis “()”. int main() indicates that the code in function main returns integer value to the operating system. void main() indicates that the code in the main block does not return any value to the operating system. • Comments and Block comments: A single comment line describes the work of code or particular statement in the program. Block comments are a lengthier description of block of code.
  • 55. Identifiers in C • Identifiers allow us to name the data and other objects in the program. • Each identified object in the computer is stored at a unique address. • Different programming languages use different syntactical rules to form identifiers. • To define a identifier in C we need to use either capital or small letters from a-z and the digits ,underscores(_) . • The first character of the identifier cannot be a digit. • The name of identifier cannot be keywords / reserved words . • C is a case-sensitive language.
  • 56.
  • 57.
  • 58. Data types in C • A type defines a set of values and a set of operations that can be applied on those values . • C language has defined set of types that can be divided into four general categories.
  • 59. • Data types in C are of three major categories. 1. Primitive data types 2. Derived data types 3. User defined data types.
  • 60. 1.Primitive data types: Character data type: Character is any value that can be represented in the computer’s alphabet.To declare a character data type the syntax is : char x;  Most of the computer systems use 1 byte to store the character data type . Integer data type: An integer data type is a number without fraction part. C supports four different sizes of the integer data type : short int, int , long int, long long int. Sizeof(short)<sizeof(int)<sizeof(long)<sizeof (long long) Each integer can be a signed or an unsigned integer. int x;
  • 61. Floating point data type: All numeric data type items with fractional part belong to float type. Keyword float is used to declare the variables of float type. float x; A variable of float type requires 4 bytes and the range of values can be stored in it is 3.48-38 to 3.48+38. Double and long double are two datatypes used to store numeric data with lengthy fracitional point Sizeof(float)<sizeof(double)<sizeof(long double).
  • 62. Constants in C • C Constants is the most fundamental and essential part of the C programming language. Constants in C are the fixed values that are used in a program, and its value remains the same during the entire execution of the program. • Constants are also called literals. • Constants can be any of the data types. • It is considered best practice to define constants using only upper- case names.
  • 63. • Constants are categorized into two basic types and each of these has its subtypes or categories.
  • 64. Numeric Constants Integer Constants: • An integer literal can be a decimal, octal, or hexadecimal constant. A prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 for octal, and nothing for decimal. • An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. The suffix can be uppercase or lowercase and can be in any order.
  • 65. • Floating Point Literals: • A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. You can represent floating point literals either in decimal form or exponential form. • While representing decimal form, you must include the decimal point, the exponent, or both; and while representing exponential form, you must include the integer part, the fractional part, or both. The signed exponent is introduced by e or E.
  • 66. Character Constants Single Character Constant: • Character literals are enclosed in single quotes, e.g., 'x' can be stored in a simple variable of char type. • A character literal can be a plain character (e.g., 'x'), an escape sequence (e.g., 't'), or a universal character (e.g., 'u02C0'). • There are certain characters in C that represent special meaning when preceded by a backslash for example, newline (n) or tab (t).
  • 67. • String Character Constant: String literals or constants are enclosed in double quotes "". A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters. • You can break a long line into multiple lines using string literals and separating them using white spaces.
  • 68. Defining Constants: • We can define constants in two different ways: (i)Using #define pre processor. (ii)Using “const” keyword. We declare a variable as constant before main using #define pre processor. Syntax: #define identifier value We can declare a variable as constant inside main using keyword “const” Syntax: const type variablename=value;
  • 69.
  • 70. C -Variables • A variable is nothing but a name given to a storage area that our programs can manipulate. Each variable in C has a specific type, which determines the size and layout of the variable's memory; the range of values that can be stored within that memory; and the set of operations that can be applied to the variable. • The name of a variable can be composed of letters, digits, and the underscore character. It must begin with either a letter or an underscore. Upper and lowercase letters are distinct because C is case-sensitive.
  • 71. Sr.No. Type & Description 1 char Typically a single octet(one byte). It is an integer type. 2 int The most natural size of integer for the machine. 3 float A single-precision floating point value. 4 double A double-precision floating point value. 5 void Represents the absence of type.
  • 72. Variable Definition in C • Variable definition tells the compiler where and how much storage to create for the variable. A variable definition specifies a data type and contains a list of one or more variables of that type Example: int i,j,k; char a,b,c;
  • 73. Lvalues and Rvalues in C • There are two kinds of expressions in C − • lvalue − Expressions that refer to a memory location are called "lvalue" expressions. An lvalue may appear as either the left-hand or right-hand side of an assignment. • rvalue −The term rvalue refers to a data value that is stored at some address in memory.An rvalue is an expression that cannot have a value assigned to it which means an rvalue may appear on the right-hand side but not on the left-hand side of an assignment.
  • 74. Input and output • Input, means to feed some data into a program. • An input can be given in the form of a file or from the command line. • C programming provides a set of built-in functions to read the given input and feed it to the program as per requirement. • Output, it means to display some data on screen, printer, or in any file. • C programming provides a set of built-in functions to output the data on the computer screen as well as to save it in text or binary files.
  • 75. • The Standard Files • C programming treats all the devices as files. So devices such as the display are addressed in the same way as files and the following three files are automatically opened when a program executes to provide access to the keyboard and screen.
  • 76. Output: • A valid C program must contain the ,main() function .The code execution starts from the main()/ function . • The printf() is a library function to send formatted output to the screen. • The function prints the string inside the double quotes. • To use printf() we need to include stdio.h headerfile in our program. Input: • In C programming scanf() is one of the commonly used function to take input from the user. • The scanf() funcition reads the formatted input
  • 78.
  • 79. TYPE CONVERSION IMPLICIT TYPE CONVERSION: Also known as ‘automatic type conversion’. Done by the compiler on its own, without any external trigger from the user. Generally takes place when in an expression more than one data type is present. In such condition type conversion (type promotion) takes place to avoid lose of data. All the data types of the variables are upgraded to the data type of the variable with largest data type. It is possible for implicit conversions to lose information, signs can be lost (when signed is implicitly converted to unsigned), and overflow can occur (when long long is implicitly converted to float).
  • 80.
  • 81. • Important Points about Implicit Conversions • Implicit type of type conversion is also called as standard type conversion. We do not require any keyword or special statements in implicit type casting. • Converting from smaller data type into larger data type is also called as type promotion. • The implicit type conversion always happens with the compatible data types. • We cannot perform implicit type casting on the data types which are not compatible with each other such as: 1.Converting float to an int will truncate the fraction part hence losing the meaning of the value. 2.Converting double to float will round up the digits. 3.Converting long int to int will cause dropping of excess high order
  • 82. EXPLICITTYPE CONVERSION • This process is also called type casting and it is user defined. Here the user can type cast the result to make it of a particular data type. • In implicit type conversion, the data type is converted automatically. There are some scenarios in which we may have to force type conversion. Suppose we have a variable div that stores the division of two operands which are declared as an int data type.
  • 83. • In this case, after the division performed on variables var1 and var2 the result stored in the variable "result" will be in an integer format. Whenever this happens, the value stored in the variable "result" loses its meaning because it does not consider the fraction part which is normally obtained in the division of two numbers. • To force the type conversion in such situations, we use explicit type casting. • It requires a type casting operator. The general syntax for type casting operations is as follows: (type-name)expression
  • 84. • It requires a type casting operator. The general syntax for type casting operations is as follows: (type-name)expression Here, • The type name is the standard 'C' language data type. • An expression can be a constant, a variable or an actual expression.
  翻译: