Introduction to C Programming Concepts
Introduction to C Programming Concepts
MODULE -I
INTRODUCTION TO C
• A computer is a powerful and versatile machine capable of performing a different task, yet it has no
intelligence or thinking power. The intelligence Quotient (I.Q) of a computer is zero
• A computer performs many tasks exactly in the same manner as it is told to do.
• This places responsibility on the user to instruct the computer in a correct and precise manner, so that
the machine is able to perform the required job in a proper way.
• In order to instruct a computer correctly, the user must have clear understanding of the problem to
be solved
• Once the problem is well-defined and a method of solving it is developed, then instructing the
computer to solve the problem becomes relatively easier task.
• Before attempt to write a computer program to solve a given problem. It is necessary to formulate
or define the problem in a precise manner
• A computer cannot solve a problem on its own. One has to provide step by step solutions of
the problem to the computer
• It is the programmer who has to write down the solution to the problem in terms of simple
operations which the computer can understand and execute.
1. Understanding the problem: Here we try to understand the problem to be solved in totally.
Before with the next stage or step, we should be absolutely sure about the objectives of the given
problem.
2. Analysing the problem: After understanding thoroughly the problem to be solved, we look
different ways of solving the problem and evaluate each of these methods. The idea here is to search
Page 1
STRUCTURED PROGRAMMING USING C UNIT - I
an appropriate solution to the problem under consideration. The end result of this stage is a broad
overview of the sequence of operations that are to be carries out to solve the given problem.
3. Developing the solution: Here the overview of the sequence of operations that was the result of
analysis stage is expanded to form a detailed step by step solution to the problem under consideration.
4. Coding and implementation: The last stage of the problem solving is the conversion of the detailed
sequence of operations in to a language that the computer can understand. Here each step is converted
to its equivalent instruction or instructions in the computer language that has been chosen for the
implantation.
Algorithmic Approach
Definition:
A set of sequential steps usually written in Ordinary Language to solve a given problem is called
Algorithm.
OR
In other words:
An algorithm can be defined as “a complete, unambiguous, finite [Link] logical steps for solving a
specific problem “
Step1. Identification of input: For an algorithm, there are quantities to be supplied called input
and these are fed externally. The input is to be identified first for any specified problem.
Step2: Identification of output: From an algorithm, at least one quantity is produced, called for
any specified problem.
Step3 : Identification the processing operations: All the calculations to be performed in order
to lead to output from the input are to be identified in an orderly manner.
Page 2
STRUCTURED PROGRAMMING USING C UNIT - I
Step4: Processing Definiteness: The instructions composing the algorithm must be clear and
there should not be any ambiguity in them.
Step5: Processing Finiteness: If we go through the algorithm, then for all cases, the algorithm
should terminate after a finite number of steps.
Step6: Possessing Effectiveness: The instructions in the algorithm must be sufficiently basic
and in practice they can be carries out easily.
Properties of Algorithm:
• It should terminate after a finite time.
• It should produce at least one output.
• It should take zero or more input.
• It should be deterministic means giving the same output for the same input case.
• Every step in the algorithm must be effective i.e. every step should do some work.
Advantages of Algorithms:
• It is easy to understand.
• An algorithm is a step-wise representation of a solution to a given problem.
• In an Algorithm the problem is broken down into smaller pieces or steps hence, it is easier
for the programmer to convert it into an actual program.
Disadvantages of Algorithms:
• Writing an algorithm takes a long time so it is time-consuming.
Page 3
STRUCTURED PROGRAMMING USING C UNIT - I
It may be possible to solve a problem in a more than one way, resulting in more than one algorithm
The choice of various algorithms depends on the factors like
[Link]: A reliable algorithm provides the same output every time it is given the same input,
assuming the execution environment remains consistent.
[Link]: It must produce results that are correct and precise
[Link] to modify: Its design is clear, logical, and structured in a way that allows for straightforward
additions, edits, or deletions of steps without causing major disruptions
The most important factor in the choice of algorithm is the time requirement to execute / run it
(Time complexity)
Note: The algorithm which will need the least time when executed, after writing code in a high-
level language with the help of a computer is considered the best
Examples of Algorithm
Pseudocode:
Example 1:
Write an algorithm that calculates the sum and average of three numbers.
Step 1: Start
Step 2: Input a, b and c values.
Step 3: Calculate sum= a+b+c
Step 4: Calculate avg = (float)sum/3
Step 5: Write sum
Step 6: Write avg
Step 7: stop.
Example 2:
Write an algorithm to convert temperature from Fahrenheit to Celsius.
Step 1: Start
Step 2: Input F value.
Step 3: Calculate C=(F-32)*5/9
Step 4: Write C
Step 5: stop.
Page 4
STRUCTURED PROGRAMMING USING C UNIT - I
Example 3: Write an algorithm which swaps two numbers/ interchange two numbers.
Using Temporary Variable Without using temporary Using bitwise operators
variable
Step 1: Start Step 1: Start Step 1: Start
Step 2: Input a, b values Step 2: Input a, b values Step 2: Input a, b values
Step 3: Calculate t=a Step 3: Calculate a=a+b Step 3: Calculate a=a^b
Step 4: Calculate a=b Step 4: Calculate b=a-b Step 4: Calculate b=a^b
Step 5: Calculate b=t Step 5: Calculate a=a-b Step 5: Calculate a=a^b
Step 6: Write a Step 6: Write a Step 6: Write a
Step 7: Write b Step 7: Write b Step 7: Write b
Step 8: Stop Step 8: Stop Step 8: Stop
Example 4:
Algorithm to find area of triangle using heron’s formula.
Sept 1:- Start
Sept 2:- Input 3 sides (a, b, c) values
Sept 3:- Calculate s= (a+b+c)/2
Sept 4:- Calculate area=sqrt( s*(s-a)*(s-b)*(s-c))
Sept 5:- Write area
Step 6:- Stop
Example 5:
Algorithm to find distance travelled by an object.
Sept 1:- Start
Sept 2:- Input (Acceleration value) a
Sept 3:- Input (Initial velocity) u
Sept 4:- Input (Time taken) t
Sept 5:- Calc d=u*t+((float)1/2)*a*(t*t)
Step 6:- Write d
Step 7:- Stop
Example 6:
Algorithm to find net salary of an employee:
Sept 1:- Start
Sept 2:- Input basic, hra, da, pf values
Sept 3:- Calculate net_salary=basic+hra+da-pf
Sept 4:- Write net_salary
Sept 5:- stop
Example 7:
Algorithm to take 3 sides of a triangle. Print whether triangle can be drawn or not.
Sept 1:- Start
Sept 2:- Write “Enter length of 3 sides of triangle”
Sept 3:- Input A,B,C
Sept 4:- if A+B>C && B+C>A && C+A>B then
Write “Triangle Can be drawn”,
goto step5.
else
Write “Triangle cannot be drawn”.
Step 5:- stop
Example 8:
Write an algorithm which finds the biggest number among three numbers.
Step 1: Start
Page 5
STRUCTURED PROGRAMMING USING C UNIT - I
Page 6
STRUCTURED PROGRAMMING USING C UNIT - I
Flowchart
Definition : A flow chart is a step by step diagrammatic representation od the logical paths to solve
a given problem
OR
It is a visual (or) graphical representation of an algorithm.
Advantages of Flowcharts
❖ Flowchart is a picture, it explains how data is read, compute and display result.
❖ Flowchart uses symbols, shapes and arrow.
❖ The symbols form a diagram that represents an algorithm.
❖ This is very helpful in understanding complicated programs.
❖ Flowchart is used before writing actual program.
❖ Flowchart should be clear, neat and easy to follow.
a. Oval: Rectangle with rounded sides is used to indicate either START/ STOP of the program.
b. Input and output indicators: Parallelograms are used to represent input and output operations.
Statements like INPUT, READ and PRINT are represented in these Parallelograms.
c. Process Indicators: - Rectangle is used to indicate any set of processing operation such as for
storing arithmetic operations.
d. Decision Makers: The diamond is used for indicating the step of decision making and therefore
known as decision box. Decision boxes are used to test the conditions or ask questions and
depending upon the answers, the appropriate actions are taken by the computer. The decision box
symbol is
Page 7
STRUCTURED PROGRAMMING USING C UNIT - I
e. Flow Lines: Flow lines indicate the direction being followed in the flowchart. In a Flowchart,
every line must have an arrow on it to indicate the direction. The arrows may be in any direction
f. On- Page connectors: Circles are used to join the different parts of a flowchart and these circles
are called on-page connectors. The uses of these connectors give a neat shape to the flowcharts. Ina
complicated problems, a flowchart may run in to several pages. The parts of the flowchart on
different pages are to be joined with each other. The parts to be joined are indicated by the circle.
g. Off-page connectors: This connector represents a break in the path of flowchart which is too
large to fit on a single page. It is similar to on-page connector. The connector symbol marks where
the algorithm ends on the first page and where it continues on the second.
Page 8
STRUCTURED PROGRAMMING USING C UNIT - I
To simplify complex Processes by breaking them into easy-to-understand visual steps which
improves communication, aids in decision making, facilitates problem solving and process
improvement, and provides clear documentation for processes, algorithms and workflow across
various fields .
Purpose of Flowchart
Page 9
STRUCTURED PROGRAMMING USING C UNIT - I
Examples
Page 10
STRUCTURED PROGRAMMING USING C UNIT - I
Example 4: Draw the flowchart which finds the biggest number among two numbers.
Page 12
STRUCTURED PROGRAMMING USING C UNIT - I
Example 6: Draw the flow chart which finds the factorial of given numbers.
Practice Sheet 1
Example 1: Draw a flowchart to print following rhyme
Twinkle, twinkle, little star,
how I wonder what you are.
Up above the world so high,
like a diamond in the sky.
History of C language
❖ In the early 1960s, computer scientists worked with low-level languages, which were hard to
write and maintain.
❖ To make programming easier, higher-level languages like ALGOL were created in 1960, but
they were still not perfect for system software.
❖ In 1966, Martin Richards developed BCPL (Basic Combined Programming Language),
mainly used for writing compilers and system software.
❖ In 1969, Ken Thompson improved BCPL to B, B is mainly used to develop UNIX operating
system.
❖ C was developed to overcome the limitations of languages like B and BCPL
❖ C is a general-purpose programming language that was originally created by Dennis Ritchie in
1972 in Bell Laboratories of AT&T Labs. It was originally intended as a system programming
language to implement the UNIX system.
❖ Dennis Ritchie began programming in C in 1972, as an effort to make UNIX
❖ By 1973, the UNIX operating system was virtually rewritten in C
❖ C is more powerful and flexible for system programming.
Variations in C:
ANSI C (C89/C90): In 1983 the American National Standards Institute (ANSI) committee
completed a final draft standard known as ANSI C
ANSI C standard was approved by International Organization for Standardization (ISO) as (C90).
C99 (1999): C99 introduced a variety of constructs, including: inline functions, variable-length
arrays, complex numbers, and other improvements to floating-point operations. C99 also introduced
the long long data type and the nature of single-line comments (//).
C11 (2011): C11 introduced many new features and addressed safety and concurrency.
C23 (2023): C23 is the latest standard, which added features such as nullptr, binary literals
Compiler vs Interpreter
A translator is used to bridge the gap between human-readable source code and machine executable
code, as computer can’t understand the human languages
Compiler:
Compilers translate the entire program into machine readable code before execution,
resulting faster, standalone programs
.
1. High Performance
Compiler translate the entire source code into machine code or byte code once, which allows the
resulting program to run much faster because its closer to the hardware
2. Standalone executable
It produces an executable file that can run on its own without needing the original source code
C Compilers:
Interpreter:
Interpreters translate and execute the code line -by-line during the runtimr,offers portability and
quick debugging of errors
[Link]:
Page 15
STRUCTURED PROGRAMMING USING C UNIT - I
Interpreted Programs are generally platform independent the same code can run on different
platforms as long as an interpreter is available
[Link] of debugging:
These identify errors line by line, allowing for easier and quicker debugging compared to compiler
Compiler Interpreter
Compiler is software which translate entire Interpreter is software which translate source
source code into machine code at once. code into machine code line by line.
Generate executable file .exe Does not generate executable file
Program executes faster program executes slowly
It shows all the errors at once. It shows errors one by one
Use more memory. Use less memory.
Examples: C, C++, JAVA Examples : python, Java Script
Recompilation is required when we do the Recompilation is not required when we do the
modifications to program,. modifications to program.
Source code does not require for later execution. Source code is required for later execution.
CPU utilization is more CPU utilization is low
Features of C
Applications of C
Operating System C is used to develop operating systems like UNIX and Linux, enabling
Development efficient management of hardware and system resources.
Embedded Systems and C powers embedded systems in devices such as automotive controllers
IoT Devices and smart home gadgets, ensuring real-time performance and precise
hardware control.
Compilers and Many compilers are written in C, facilitating the translation of high-
Interpreters level code into machine-executable instructions.
Database Systems High-performance databases like MySQL and Oracle utilize C for
efficient data management, query processing, and transaction handling.
Game Development and C is used in developing game engines for titles like Doom and Quake,
Graphics enabling high-performance graphics rendering and real-time processing.
System Utilities and Essential utilities such as grep and the GNU Core Utilities are built with
Command-Line Tools C, providing fast and powerful system-level functionalities.
Structure of C Program
A “C‟ program is a group of building blocks called functions. A function is a subroutine that
may include one or more statements designed to perform a specific task. To write a C
program we first create functions and then put them together. Any C program may contain
one or more sections as shown in the figure.
Page 17
STRUCTURED PROGRAMMING USING C UNIT - I
Function-n
Documentation Section:
To enhance the readability of the program, programmers can provide comments about the
program in this section. The comments are included between the delimiters /* and */.
Example:
/*Write a program to find sum of 2 numbers */
These statements are not executable rather they are ignored by the compiler. Comments can
be used anywhere in the program.
Link Section:
This section instructs the compiler to link functions from the “C‟ library. Library functions
are grouped category wise and stored in different files known as header files. If we want to
access the functions stored in the library, it is necessary to tell the compiler about the files to
be accessed. This can be done through a preprocessor directive #include <filename>
Ex: #include<stdio.h>
This statement instructs the compiler to copy the content of “stdio.h” into our program
before starting the compiling step.
Definition Section:
It is used to define symbolic constants and to define macros. The preprocessor directive
#define is used for the purpose.
No2=no1+10
Main( ) Function Section:
The main( ) is a special function used by the C system to tell the computer where the program
starts. Every program must have exactly one main function. This section has two parts
a) Declaration part
b) Execution part
The declaration part declares all the variables that are used in the executable part. There
is at least one statement in the executable part. These two parts can appear between the
opening and closing braces. In all C programs execution begins at this opening brace and
ends at this closing brace. The closing brace of this function is the logical end of the program.
All the declaration and executable statements end with a semicolon.
Example :
void main()
{
Declaration part
Execution part
}
Subprogram Section:
This section contains user defined functions that are used in the main function. User defined
functions are generally placed immediately after the main function.
All Sections except the main function section may be absent when they are not required.
Example Program:
/* A Sample C program */ /* documentation section*/
#include <stdio.h> /* Link section*/
#define PI 3.14 /* Definition section*/
int area; /*global variables declaration part*/
/*main( ) function section begins*/
main( )
{
int radius; /*local variables declaration part*/
printf(“Enter radius : “);
scanf(“%d”, &radius);
find_area(radius);
printf(“area of the circle = %d”,area);
}
/* main() function section ends*/
/* sub function section begins*/
void find_area(int radius)
{
area=PI*radius*radius;
}
/* sub function section ends*/
Page 19
STRUCTURED PROGRAMMING USING C UNIT - I
Tokens of C Language
Tokens in C are the most important elements to be used in creating a program in C. We can define
the token as the smallest individual element in C. For `example, we cannot create a sentence without
using words; similarly, we cannot create a program in C without using tokens. Therefore, we can say
that tokens in C are basic components for creating a program.
1. Identifiers :-
Identifiers are the names allocated to variables or methods or functions or user defined
references like arrays, structures, unions, enums and constants. Identifiers names should
be unique. Identifiers names should be meaningful. These consist of a sequence of letters,
digits and underscore. Both uppercase and lowercase letters are permitted but commonly use
lower case letters. Name of identifier is Case Sensitive. Identifiers cannot be used as
keywords. Identifiers should be written in such a way that it is meaningful, short, and easy to
read.
Examples 1:
int a;
char ch;
Here “a” and “ch” are identifiers of variables
Example 2:
void main()
{
//code
}
Here main is identifier of function.
Example 3:
struct Student
{
int no;
char sname[100];
};
Here Student is identifier of structure.
Example 4:
#define PI 3.14
Page 20
STRUCTURED PROGRAMMING USING C UNIT - I
2. Keywords: -
Keywords are the pre-defined identifiers. Keywords are the system defined identifiers.
Keywords are the reserved words. Keywords are words that have special meaning. We
should not change the meaning of keywords. If we try the change its meaning then we will
get error. Keywords are part of the syntax. These cannot be used as an identifier. All
keywords must be written in lowercase. C language provides 32 keywords.
Examples
auto double int struct
break else long switch
case enum register typedef
char extern return union
Const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
3. Constants / Literals
Constant is a container that retains its value until program termination. The value of constant
cannot be changed. If we try to change the value of constant then we will get an error. “C‟
supports several types of constants as shown in the figure. Constant name should be
represented in upper case.
Page 21
STRUCTURED PROGRAMMING USING C UNIT - I
Real Constants: A Real constant or floating point constant is a sequence of digits with a
decimal point. No commas, no blank spaces are allowed. It could be either positive or negative.
If no sign proceeds it is assumed to be positive.
Ex: valid floating-point constants 0.00083 , -0.35 , 435.98 , 95
A real constant may also be expressed in exponential (or scientific) notation. The scientific
notation is often used to express numbers that are very small or very large. For ex, that
0.000000011 is written as 1.1 × 10-8. The general form is
Mantissa e exponent
The mantissa is either a real number expressed in decimal notation or an integer. The exponent
is an integer number with an optional + or – sign.
Ex: valid floating-point constants: 0.65e4 , 12e-2, 1.5E+5
Invalid floating point constants:
6,700.25 commas is not permitted
5e+2.5 exponents must be an integer
Floating point constants are normally represented as double precision quantities. However, the
suffixes f or F may be used to force single precision and l or L to extend double precision.
Character Constants: Any single character enclosed with in pair of single quotation marks is
called a character constant.
Ex: ‘5’, ‘x’, ‘ ‘
The last constant is a blank space. The character constant ‘5’ is not the same as 5.
Character Constants have integer values known as ASCII values. Since each character
constant represent an integer value it is also possible to perform arithmetic operations on
character constants.
String Constant: A String Constant is a sequence of characters enclosed in double quotes. The
characters may be letters, numbers, special characters and blank space.
Ex: “VVIT”, “P”, “5+3”,
The character constant (ex: ‘p’) is not equivalent to the string constant (ex: “p”). A string
constant does not have an associated ASCII value, whereas character constant has an integer
value.
4. Special Characters :
Some special characters are used in C, and they have a special meaning which cannot be used
for another purpose.
Page 22
STRUCTURED PROGRAMMING USING C UNIT - I
o Square brackets [ ]: The opening and closing brackets represent the single and
multidimensional subscripts.
o Simple brackets ( ): It is used in function declaration and function calling. For example,
printf() is a pre-defined function.
o Curly braces { }: It is used in the opening and closing of the code. It is used in the opening
and closing of the loops.
o Comma (,): It is used for separating for more than one statement and for example, separating
function parameters in a function call, separating the variable when printing the value of
more than one variable using a single printf statement.
o Hash/pre-processor (#): It is used for pre-processor directive. It basically denotes that we
are using the header file.
o Asterisk (*): This symbol is used to represent pointers and also used as an operator for
multiplication.
o Tilde (~): It is used as a destructor to free memory.
o Period (.): It is used to access a member of a structure or a union.
5. Strings :- Strings are nothing but an array of characters ended with a null character (‘\0’). This
null character indicates the end of the string. Strings are always enclosed in double quotes.
Example : +, -, *, /, %, =, ==, !=, >, <, >=, <=, &&, ||, ++, -- etc..
• These functions are used to control how data is read from input devices and written to
output devices
• These functions use format specifiers to define the datatype and representation of input
and output
• The primary formatted I/O functions are
o Printf()
o Scanf ()
Usually the input is given & output is viewed on the screen with the help of input & output
functions in C. The standard or regularly used I/O functions are:
printf () :–
------------------------------
• It stands for print formatted.
• It is a formatted output function.
• It sends a formatted string to output devices.
• It is used to print output on screen. It is a general purpose output function.
• It can print any type of data.
• It can print multiple values at a time.
• It executes from right side to left side. It was defined in “stdio.h”.
• It returns how many bytes of information get printed successfully on screen.
Page 23
STRUCTURED PROGRAMMING USING C UNIT - I
Syntax :
Here formatted string contains the text to be displayed on screen. The general form of formatted
string is “%[flag][width][.precision][length]specifier”.
Explanation :
printf(“% - 10.2lf”,salary);
Here
“-“ is called flag
10 is width
2 is precision
“l” is length
“f” is specifir
Page 24
STRUCTURED PROGRAMMING USING C UNIT - I
• getchar(): Reads a single character from the standard input and returns its integer value
(ASCII value). It requires the Enter key to be pressed.
char ch = getchar();
• getch(): Reads a single character from the keyboard without echoing it to the screen and
without requiring the Enter key. (Requires conio.h).
char ch = getch();
• gets(): Reads a string from the standard input until a newline character is encountered.
char str[100];
gets(str);
These functions display data to the standard output (console) without specific formatting.
char ch = 'A';
putchar(ch);
• putch(): Displays a single character to the console. (Requires conio.h).
char ch = 'B';
putch(ch);
• puts(): Displays a string to the standard output, automatically adding a newline character at
the end.
char str[] = "Hello, World!";
puts(str);
Page 25
STRUCTURED PROGRAMMING USING C UNIT - I
Format Specifiers:
That tell a program how to format and display data in input/output functions
C language provides some tools using which we can format the input and output. They are generally
inserted between the % sign and the format specifier symbol Some of them are as follows:
1. A minus(-) sign tells left alignment.
2. A number after % specifies the minimum field width to be printed if the characters are less
than the size of the width the remaining space is filled with space and if it is greater then it is
printed as it is without truncation.
3. A period( . ) symbol separates field width with precision.
Example :
Page 26
STRUCTURED PROGRAMMING USING C UNIT - I
#include <stdio.h>
int main()
{
char str[] = "Welcome";
printf("%20s\n", str);
printf("%-20s\n", str);
printf("%20.5s\n", str);
printf("%-20.5s\n", str);
return 0;
}
Output :
Welcome
Welcome
Welco
Welco
Escape Sequences:
Escape sequences are special character combinations, beginning with a backslash (\), that represent
characters or actions not easily typed directly, such as a new line (\n) or a double quote (\")
Escape
Meaning Example Code Output
Sequence
Hello
\n Newline printf("Hello\nWorld");
World
\t Horizontal tab printf("A\tB"); A B
\\ Backslash printf("\\"); \
\" Double quote printf("\"Hello\""); "Hello"
\' Single quote printf("\'A\'"); 'A'
\a Alert (bell) printf("\a"); Beep sound
\b Backspace printf("ABC\bD"); ABD
\f Form feed printf("Hello\fWorld"); Page break effect
\r Carriage return printf("Hello\rWorld"); World
Hello (vertical tab)
\v Vertical tab printf("Hello\vWorld");
World
\0 Null character (string terminator) printf("Hi\0World"); Hi
\ooo Octal value (ooo = octal digits) printf("\101"); A
Hexadecimal value (hh = hex
\xhh printf("\x41"); A
digits)
Page 27
STRUCTURED PROGRAMMING USING C UNIT - I
ASCII TABLE :
ASCII (American Standard Code for Information Interchange) is a 7-bit character encoding
standard with 128 values (0–127) representing letters, digits, symbols, and control codes.
Dec Hex Char Description Binary
0 00 NUL Null character 00000000
1 01 SOH Start of Header 00000001
2 02 STX Start of Text 00000010
3 03 ETX End of Text 00000011
4 04 EOT End of Transmission 00000100
5 05 ENQ Enquiry 00000101
6 06 ACK Acknowledge 00000110
7 07 BEL Bell 00000111
8 08 BS Backspace 00001000
9 09 TAB Horizontal Tab 00001001
10 0A LF Line Feed (newline) 00001010
11 0B VT Vertical Tab 00001011
12 0C FF Form Feed 00001100
13 0D CR Carriage Return 00001101
14 0E SO Shift Out 00001110
15 0F SI Shift In 00001111
16 10 DLE Data Link Escape 00010000
17 11 DC1 Device Control 1 00010001
18 12 DC2 Device Control 2 00010010
19 13 DC3 Device Control 3 00010011
20 14 DC4 Device Control 4 00010100
21 15 NAK Negative Acknowledge 00010101
22 16 SYN Synchronous Idle 00010110
End of Transmission
23 17 ETB 00010111
Block
24 18 CAN Cancel 00011000
25 19 EM End of Medium 00011001
26 1A SUB Substitute 00011010
27 1B ESC Escape 00011011
28 1C FS File Separator 00011100
29 1D GS Group Separator 00011101
30 1E RS Record Separator 00011110
31 1F US Unit Separator 00011111
32 20 SPACE Space 00100000
33 21 ! Exclamation mark 00100001
34 22 " Double quote 00100010
Page 28
STRUCTURED PROGRAMMING USING C UNIT - I
Page 29
STRUCTURED PROGRAMMING USING C UNIT - I
Page 30
STRUCTURED PROGRAMMING USING C UNIT - I
Number System :
There are four common types of number systems based on the radix or base of the number
Page 31
STRUCTURED PROGRAMMING USING C UNIT - I
Page 32
STRUCTURED PROGRAMMING USING C UNIT - I
•Take the fractional part of the result and repeat the multiplication.
•Continue until the fractional part becomes 0 or reaches the desired precision.
•The binary equivalent is the integer parts recorded in sequence.
Example: (10.25)10
• For each digit in the hexadecimal number, find its corresponding 4-bit binary equivalent and
write them down sequentially.
Example: (3A)16
• (3)16 = (0011)2
• (A)16 = (1010)2
Thus, (3A)16 = (00111010)2
Page 34
STRUCTURED PROGRAMMING USING C UNIT - I
Example: (111101101)2
111 101 101
|||
755
Thus, (111101101)2 = (755)8
Page 35
STRUCTURED PROGRAMMING USING C UNIT - I
Page 36