SlidePub
Home
Categories
Login
Register
Home
Technology
Module 1 - Introduction to C Programming.pptm (1).pdf
Module 1 - Introduction to C Programming.pptm (1).pdf
SudipDebnath20
80 views
98 slides
May 27, 2024
Slide
1
of 98
Previous
Next
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
About This Presentation
c programming
Size:
5.64 MB
Language:
en
Added:
May 27, 2024
Slides:
98 pages
Slide Content
Slide 1
PRPEARED BY: PROF. NEHA HARDE ©
C PROGRAMMING
Module 1
Introduction to C Programming
Course Outcome (CO1):
Understand the basic syntax and semantics of C.
Slide 2
PRPEARED BY: PROF. NEHA HARDE ©
What is Computer ?
Characteristics of computer
Benefits of computer
Computer Components
Input Devices
Output Devices
Central Processing Unit
Memory Unit
Introduction to Components
of a computer system
Slide 3
PRPEARED BY: PROF. NEHA HARDE ©
WHAT IS COMPUTER ?
A computer is a programmable electronic
device that accepts raw data as input and
processes it with a set of instructions (a
program) to produce the result as output
The father of the
computer:
Charles Babbage
Slide 4
PRPEARED BY: PROF. NEHA HARDE ©
WHAT IS COMPUTER ?
Slide 5
PRPEARED BY: PROF. NEHA HARDE ©
CHARACTERISTICS OF COMPUTER
Speed Memory Accuracy Diligence Versatile
Multitask
ing
Slide 6
PRPEARED BY: PROF. NEHA HARDE ©
BENEFITS OF COMPUTER
Storage
Increases
Productivity
Connects
to the
Internet
Improves
ability
Provides
an
entertainm
ent
Organizes
data and
information
Slide 7
PRPEARED BY: PROF. NEHA HARDE ©
COMPUTER COMPONENTS
Slide 8
PRPEARED BY: PROF. NEHA HARDE ©
COMPUTER COMPONENTS
Input is any data or instruction given to the computer
Input device enables the user to send data, information, or control signals
to a computer
The prime purpose of input devices are to translate data and information
from human-readable format into electrical impulses
1.Input Devices
Slide 9
PRPEARED BY: PROF. NEHA HARDE ©
INPUT DEVICES
Keyboard is a basic input device that is
used to enter data into a computer or any
other electronic device by pressing keys
Mouse is a pointing hand-held input
device which is used to move cursor or
pointer across the screen
Slide 10
PRPEARED BY: PROF. NEHA HARDE ©
Scanner scans the picture or a document
converts it into a digital format and is
displayed on the screen as an output
Joystick is a pointing input device like a
mouse and movement of stick controls the
cursor or pointer on the screen
INPUT DEVICES
Slide 11
PRPEARED BY: PROF. NEHA HARDE ©
Light pen is like a pen. The tip of the light
pen contains a light-sensitive detector that
enables the user to point to or select objects
on the display screen
Microphone is used to input the sound to
presentations and with webcams for video
conferencing
INPUT DEVICES
Slide 12
PRPEARED BY: PROF. NEHA HARDE ©
COMPUTER COMPONENTS
The output device displays the result of the processing of raw data that is
entered in the computer through an input device
It is used to bring out the information from the computer
2. Output Devices
Slide 13
PRPEARED BY: PROF. NEHA HARDE ©
Monitor is the display unit or screen of the
computer that displays the processed data or
information as text, images, audio or video
Printer is a device that prints text, images or
any information on paper producing hard
copy of the information
OUTPUT DEVICES
Slide 14
PRPEARED BY: PROF. NEHA HARDE ©
A projector is an output device that enables
the user to project the output onto a large
surface such as a big screen or wall
Speaker is an output device connected to a
computer's sound card that outputs sounds
generated by the computer
OUTPUT DEVICES
Slide 15
PRPEARED BY: PROF. NEHA HARDE ©
COMPUTER COMPONENTS
Brain of the computer system
It receives instructions from both the hardware and
active software and produces output accordingly
3. Central Processing Unit
Slide 16
PRPEARED BY: PROF. NEHA HARDE ©
CENTRAL PROCESSING UNIT (CPU)
Control Unit is used to control the entire working
of a computer system and it controls the transfer of
data between memory and input/output devices or
I/O devices
Arithmetic and Logic Unit is designed to
perform all the basic arithmetic operations and
logical operations
Slide 17
PRPEARED BY: PROF. NEHA HARDE ©
COMPUTER COMPONENTS
Memory unit is used to retain the program instruction and data for processing
Two types of memory:
Primary Memory
Secondary Memory
4. Memory Unit
Slide 18
PRPEARED BY: PROF. NEHA HARDE ©
MEMORY UNIT
Main memory of the computer
Directly accessed by the
CPU
Volatile
Faster access
Semiconductor Memory - Expensive
Less storage capacity
Primary Memory
Slide 19
PRPEARED BY: PROF. NEHA HARDE ©
Primary Memory
MEMORY UNIT
Slide 20
PRPEARED BY: PROF. NEHA HARDE ©
Primary Memory
MEMORY UNIT
Slide 21
PRPEARED BY: PROF. NEHA HARDE ©
External Memory
High storage capacity
Permanent storage
Non volatile
Slower access
Magnetic or optical memory - Less Expensive
Secondary Memory
MEMORY UNIT
Slide 22
PRPEARED BY: PROF. NEHA HARDE ©
MEMORY UNIT
Slide 23
PRPEARED BY: PROF. NEHA HARDE ©
What is Algorithm ?
Characteristics of algorithm
How to write an algorithm ?
Flowchart
Flowchart Symbols
How to draw a flowchart ?
Introduction to Algorithm
and Flowchart
Slide 24
PRPEARED BY: PROF. NEHA HARDE ©
WHAT IS ALGORITHM
An algorithm can be defined as a finite set of steps, which has to be followed
while carrying out a particular problem
An algorithm is a distinct computational procedure that takes input as a set of
values and results in the output as a set of values by solving the problem
Slide 25
PRPEARED BY: PROF. NEHA HARDE ©
CHARACTERISTICS OF ALGORITHM
•Well defined zero or more inputs Input
•Generate at least one output Output
•Each Instruction should be clear Unambiguous
•Algorithm should terminate after executing
finite no. of instructions
Finiteness
•Every instruction should be fundamental to be
carried out, in principle
Effectiveness
Slide 26
PRPEARED BY: PROF. NEHA HARDE ©
HOW TO WRITE AN ALGORITHM
Step 1: Start
Step 2: Read values num1 and num2.
Step 3: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step4: Display sum
Step 5: Stop
Example: Add two numbers
Slide 27
PRPEARED BY: PROF. NEHA HARDE ©
HOW TO WRITE AN ALGORITHM
Step 1: Start
Step 2: Read variables a, b and c.
Step 3: If a > b
If a > c
Display a is the largest number.
Else
Display c is the largest number.
Else
If b > c
Display b is the largest number.
Else
Display c is the greatest number.
Step 4: Stop
Example:
Find the largest number among three numbers
Slide 28
PRPEARED BY: PROF. NEHA HARDE ©
FLOWCHART
A flowchart is a visual representation of the sequence
of steps and decisions needed to perform a process
A flowchart is a powerful business tool - With proper
design and construction, it communicates the steps in
a process very effectively and efficiently.
Slide 29
PRPEARED BY: PROF. NEHA HARDE ©
FLOWCHART SYMBOLS
Slide 30
PRPEARED BY: PROF. NEHA HARDE ©
HOW TO DRAW A FLOWCHART
Example: Add two numbers
Step 1: Start
Step 2: Read values num1 and num2.
Step 3: Add num1 and num2 and assign the result to sum.
sum←num1+num2
Step 5: Display sum
Step 5: Stop
Slide 31
PRPEARED BY: PROF. NEHA HARDE ©
HOW TO DRAW A FLOWCHART
Example:
Find the largest number among three numbers
Start
Input a, b, c
Is
a>b ?
Is a>c
?
Yes
Is b>c
?
No
Print a is the
largest number
Yes
Print c is the
largest number
NoNo
Print b is the
largest number
Yes
End
Slide 32
PRPEARED BY: PROF. NEHA HARDE ©
What is Programming Language ?
Types of Programming Languages
What is Compiler ?
What is Interpreter ?
Compiler Vs Interpreter
C Programming Language
Features of C
Applications of C
C Program Structure
Compilation Process
Introduction to C Programming
Slide 33
PRPEARED BY: PROF. NEHA HARDE ©
WHAT IS PROGRAMMING LANGUAGE
A programming language is a
computer language that is used
by
programmers (developers) to communicate with computers
Slide 34
PRPEARED BY: PROF. NEHA HARDE ©
TYPES OF PROGRAMMING LANGUAGES
Low Level Programming Language
High Level Programming Language
Middle Level Programming Language
Machine Dependent
Runs without the need of compiler and interpreter
Example: 0 1 (Binary)
User friendly
Used to develop applications, websites
Requires compiler and interpreter
Example: Python, C, C++, Java
Related to both high level and Machine level
languages
Requires Assembler
Example: Assembly Language
Slide 35
PRPEARED BY: PROF. NEHA HARDE ©
TYPES OF PROGRAMMING LANGUAGES
Slide 36
PRPEARED BY: PROF. NEHA HARDE ©
WHAT IS COMPILER ?
A compiler is a computer program that transforms code written
in a high-level programming language into the machine code
Slide 37
PRPEARED BY: PROF. NEHA HARDE ©
WHAT IS INTERPRETER ?
An interpreter is a computer program, which coverts each
high-level program statement into the machine code.
Slide 38
PRPEARED BY: PROF. NEHA HARDE ©
COMPILER VS INTERPRETER
Slide 39
PRPEARED BY: PROF. NEHA HARDE ©
COMPILER VS INTERPRETER
Slide 40
PRPEARED BY: PROF. NEHA HARDE ©
C PROGRAMMING LANGUAGE
C
is a general-purpose, structured programming language
that is extremely popular, simple, and flexible to use
Developed in 1972 by Dennis Ritchie at bell laboratories of
AT&T, located in the U.S.A.
Mother of Programming Languages - C programming is
considered as the base for other programming languages
Slide 41
PRPEARED BY: PROF. NEHA HARDE ©
FEATURES OF C
Slide 42
PRPEARED BY: PROF. NEHA HARDE ©
APPLICATIONS OF C
Slide 43
PRPEARED BY: PROF. NEHA HARDE ©
C PROGRAM STRUCTURE
/* C program to Print Hello World */
#include<stdio.h>
#define MAX 10
int a = 20;
int main()
{
printf(“Hello World”);
printf(“a = %d”, a);
return 0;
}
Slide 44
PRPEARED BY: PROF. NEHA HARDE ©
COMPILATION PROCESS
Slide 45
PRPEARED BY: PROF. NEHA HARDE ©
Constants
Keywords
Identifiers
Variables
Types of Variables
Data Types
Operators
Unary Operators
Binary Operators
Ternary Operators
Operator Precedence
Operator Associativity
Input and Output Functions
Format Specifiers
Formatted I/O Functions
Unformatted I/O Functions
Basics of C
Slide 46
PRPEARED BY: PROF. NEHA HARDE ©
CONSTANTS IN C
Constants or literals are like variables, but their values are
fixed
Once defined, value of the constant cannot be changed
Slide 47
PRPEARED BY: PROF. NEHA HARDE ©
CONSTANTS IN C
1. Numeric Constants
Integer Constants: Sequence of digits
•Decimal Integer
Example:
12250 -4500 0
•Octal Integer
Example:
05 0632
•Hexadecimal Integer
Example:
0X6A 0x79BD 0X346
Rules for Constructing Integer Constants:
An Integer constant must have at least one
digit
It can be either positive or negative
No commas or blanks or special symbols are
allowed
Allowable range is -32768 to 32767
Slide 48
PRPEARED BY: PROF. NEHA HARDE ©
CONSTANTS IN C
1. Numeric Constants
Real Constants: (Floating point constants)
Numbers having fractional part
Example:
34.89 -22.1845 +0.76
Exponential Representation of Real Constants:
Example:
6.78e3 -0.45E-4
Rules for Constructing Real Constants:
An real constant must have at least one digit
and decimal point
It can be either positive or negative
No commas or blanks or special symbols are
allowed
Mantissa Exponent
Slide 49
PRPEARED BY: PROF. NEHA HARDE ©
CONSTANTS IN C
2. Character Constants
Single Character Constants:
Single character or Single Digit or Single Special
Symbol enclosed within single inverted commas
Example:
‘A’ ‘m’ ‘8’ ‘@’
Note: 8 ≠ ‘8’
Rules for Constructing Single Character Constants:
Length of character constant can be 1 character
Character constant should be in single inverted
commas
Slide 50
PRPEARED BY: PROF. NEHA HARDE ©
CONSTANTS IN C
2. Character Constants
String Constants:
Sequence of characters enclosed within double quotes
Example:
“college” “m” “a8bn”
Note:
1. ‘a’ ≠ “a”
2. Compiler will add ‘\0’ (null character at the end of
the string
Rules for Constructing String Constants:
String constants should be enclosed within
double quotes
String constants can be of any length
String constant ends with a null character
assigned to it by the compiler
Slide 51
PRPEARED BY: PROF. NEHA HARDE ©
CONSTANTS IN C
2. Character Constants
Backslash Character Constants: (Escape Sequences)
Backslash characters have a specific meaning which is
known to the compiler
Slide 52
PRPEARED BY: PROF. NEHA HARDE ©
CONSTANTS IN C
Defining Constant
1.Using const Keyword
Syntax:
const data_type constant_name = value;
Example:
const int A = 10;
2. Using #define pre-processor
Syntax:
#define const_name value
Example:
#define PI 3.14
Two ways to define constants
Slide 53
PRPEARED BY: PROF. NEHA HARDE ©
KEYWORDS IN C
Keywords are the reserved words having specific
meaning defined to the compiler
32 Keywords in C
Keywords cannot be used as a variable names
Slide 54
PRPEARED BY: PROF. NEHA HARDE ©
KEYWORDS IN C
Slide 55
PRPEARED BY: PROF. NEHA HARDE ©
IDENTIFIERS IN C
Identifiers represent the name in the C program; Like names of
variables, functions, arrays, structures, unions, labels
Note:
C is a case
sensitive language
Sum ≠ sum
Slide 56
PRPEARED BY: PROF. NEHA HARDE ©
IDENTIFIERS IN C
Rules for Constructing String Constants:
An identifier can only have alphanumeric characters (a-z , A-Z , 0-9) (i.e. letters & digits)
and underscore( _ ) symbol.
Identifier names must be unique
The first character must be an alphabet or underscore.
You cannot use a keyword as identifiers.
Only the first thirty-one (31) characters are significant.
It must not contain white spaces.
Identifiers are case-sensitive.
Slide 57
PRPEARED BY: PROF. NEHA HARDE ©
VARIABLES IN C
A
variable is a name given to the memory location where
data is stored depending upon the type of the variable
Variable Declaration:
Syntax:
data_type variable_name;
Example:
int choice;
char ans;
10 20
5 ‘a’
n1
chn3
n2
100
200140
104
Slide 58
PRPEARED BY: PROF. NEHA HARDE ©
VARIABLES IN C
Variable Initialization:
Variable initialization means
assigning some value to that variable
Example:
int ch;
ch = 10;
OR
Variable Declaration and initialization on the same line
int ch = 10;
Slide 59
PRPEARED BY: PROF. NEHA HARDE ©
TYPES OF VARIABLES
Slide 60
PRPEARED BY: PROF. NEHA HARDE ©
TYPES OF VARIABLES
1. Local Variables
A variable that is declared inside the function or block is called a local variable
Scope: Lies within the function or block of code
Life: Stay in the memory till the end of the program
Example:
void fun1()
{
int lv = 20;
printf(“value = %d”, lv);
}
Slide 61
PRPEARED BY: PROF. NEHA HARDE ©
TYPES OF VARIABLES
2. Global Variables
A variable that is declared outside the function or block is called a global variable
Value of global variable can be changed by any function
Scope: Available to all functions
Life: Stay in the memory till the end of the program
Example:
int gv = 10;
void fun1()
{
int lv = 20;
printf(“value of lv = %d \n value of gv= %d ”, lv, gv);
}
Slide 62
PRPEARED BY: PROF. NEHA HARDE ©
TYPES OF VARIABLES
3. Static Variables
A variable declared with static keyword which retains its value within the function calls is
called as static variable
Cannot be initialized again
Scope: Local to the function or block
Life: Value retains within the function calls
Example:
static int a = 11;
Slide 63
PRPEARED BY: PROF. NEHA HARDE ©
TYPES OF VARIABLES
4. Automatic Variables
All variables in C that are declared inside the block, are automatic variables by default
Explicit declaration using auto keyword
Scope: Local to the function or block
Life: Till the end of the block
Example:
void fun1()
{
int a = 10; // Automatic
auto int b = 20;
}
Slide 64
PRPEARED BY: PROF. NEHA HARDE ©
TYPES OF VARIABLES
5. External Variables
We can share a variable in multiple C source files by using an external variable
extern keyword is used
Scope: Global in other files too
Life: Till the end of the program
Example:
extern int a;
Pro1.c
extern int a = 10;
Pro2.c
#include<stdio.h>
#include “pro1.h”
Slide 65
PRPEARED BY: PROF. NEHA HARDE ©
DATATYPES IN C
Data types refer to the characteristics of data stored into a variable
Data type helps you find Size, range and type of value
C Data Types are used to:
Identify the type of a variable when it declared
Identify the type of the return value of a function
Identify the type of a parameter expected by a function
10 20
5 ‘a’
n1
chn3
n2
100
200140
104
Slide 66
PRPEARED BY: PROF. NEHA HARDE ©
DATATYPES IN C
Slide 67
PRPEARED BY: PROF. NEHA HARDE ©
DATATYPES IN C
Primitive Data Types
2
??????????????????−1
Slide 68
PRPEARED BY: PROF. NEHA HARDE ©
DATATYPES IN C
Primitive Data Types
Slide 69
PRPEARED BY: PROF. NEHA HARDE ©
DATATYPES IN C
Primitive Data Types
2
??????????????????
−1
Slide 70
PRPEARED BY: PROF. NEHA HARDE ©
DATATYPES IN C
Primitive Data Types
Slide 71
PRPEARED BY: PROF. NEHA HARDE ©
OPERATORS IN C
C operators are symbols that are used to perform mathematical or logical manipulation
The C programming language is rich with built-in operators
Operators take part in a program for manipulating data and variables and form a part of
the mathematical or logical expressions
Mathematical Expression:
Slide 72
PRPEARED BY: PROF. NEHA HARDE ©
OPERATORS IN C
Operators are symbols or a set of symbols that change or assign values, combine
values, or check or verify values in your code
Types of Operators:
1.Unary Operator
2.Binary Operator
3.Ternary Operator
Slide 73
PRPEARED BY: PROF. NEHA HARDE ©
UNARY OPERATORS
Unary Operators are the operators which require single operand to perform any action
1.Sizeof
2.Unary minus
3.Logical NOT
4.Increment
5.Decrement
6.& (Addrss of)
7.* (Value of)
Slide 74
PRPEARED BY: PROF. NEHA HARDE ©
UNARY OPERATORS
Unary Operators are the operators which require single operand to perform any action
1.sizeof: return the size of an operand in bytes (prefix Operator)
Example: sizeof(operand)
2. unary minus: it negates a value (Prefix Operator)
Example: a = -10;
b = -a;
3. Logical NOT: The logical NOT operator inverts the value of a Boolean variable (Prefix Operator)
Example: c = True
a = !c;
Slide 75
PRPEARED BY: PROF. NEHA HARDE ©
UNARY OPERATORS
Unary Operators are the operators which require single operand to perform any action
4. Increment: (Prefix and Postfix)
Increment : ++ (increases a numeric value by 1) a = a + 1
a)Post Increment:
Example: a++
b)Pre Increment:
Example: ++a
Slide 76
PRPEARED BY: PROF. NEHA HARDE ©
UNARY OPERATORS
Unary Operators are the operators which require single operand to perform any action
5. Decrement: (Postfix and Prefix)
Decrement: -- (decreases a numeric value by 1) a = a – 1
a)Post Decrement:
Example: a--
b)Pre Decrement:
Example: --a
Slide 77
PRPEARED BY: PROF. NEHA HARDE ©
UNARY OPERATORS
Unary Operators are the operators which require single operand to perform any action
6. & (Address of): Returns the address of a variable (Prefix Operator)
Example: &a
7. * (Value of): Returns value stored at the address (Works with pointers)
Example: *a
Slide 78
PRPEARED BY: PROF. NEHA HARDE ©
BINARY OPERATORS
Binary Operators are the operators which require two operands to perform any action
1.Arithmetic
2.Relational
3.Logical
4.Bitwise
5.Assignment
Slide 79
PRPEARED BY: PROF. NEHA HARDE ©
BINARY OPERATORS
1.Arithmetic Operators: used to perform arithmetic/mathematical operations
Consider a = 20 and b = 10
Slide 80
PRPEARED BY: PROF. NEHA HARDE ©
BINARY OPERATORS
2. Relational Operators: used to compare two values
Consider
a = 5
b = 10
Slide 81
PRPEARED BY: PROF. NEHA HARDE ©
BINARY OPERATORS
3. Logical Operators: used to test more than one condition
Consider x = 10 and y = 20
Slide 82
PRPEARED BY: PROF. NEHA HARDE ©
BINARY OPERATORS
4. Bitwise Operators: used to perform bit level operations
Slide 83
PRPEARED BY: PROF. NEHA HARDE ©
BINARY OPERATORS
5. Assignment Operators: used for assigning a value to a variable
Slide 84
PRPEARED BY: PROF. NEHA HARDE ©
TERNARY OPERATOR
The ternary operator is also called as “Conditional Operator”
Syntax:
Condition ? expression1 : expression2
Example:
x = a > b ? a+10 : b;
A ternary operator is a short form of if-else
Slide 85
PRPEARED BY: PROF. NEHA HARDE ©
OPERATOR PRECEDENCE
The precedence of operators determines which operator is
executed first if there is
more than one operator in an expression
Two ways to solve
= (10+20)*30
=900
=10+(20*30)
=610
Slide 86
PRPEARED BY: PROF. NEHA HARDE ©
OPERATOR PRECEDENCE
Problem:
To generate machine level instructions that could properly evaluate arithmetic expression
Understand the meaning of an expression:
Decide the order in which the operations are to be carried out
Fix the order of evaluation, assign each operator a priority
X = a / b * c - d
X = (a / b * c) - d
X = (a / b)* (c – d)
Slide 87
PRPEARED BY: PROF. NEHA HARDE ©
OPERATOR PRECEDENCE
Understand the meaning of an expression:
Evaluate the expression from right to left or left to right (This order of
evaluation, from left to right or right to left, is called associativity)
A+ B - C
A + (B – C)
(A + B) - C
Operators Precedence and Associativity are two characteristics of operators that
determine the evaluation order of sub-expressions in absence of brackets
Slide 88
PRPEARED BY: PROF. NEHA HARDE ©
OPERATOR PRECEDENCE
Slide 89
PRPEARED BY: PROF. NEHA HARDE ©
OPERATOR ASSOCIATIVITY
Slide 90
PRPEARED BY: PROF. NEHA HARDE ©
PRACTICE QUESTION
What is the output of the code:
#include<stdio.h>
int main()
{
int a = 15;
printf("\n %d %d %d %d", a++, --a, a--, ++a);
// Updated
//Printed
printf("\n %d %d %d", a++, a--, --a);
return 0;
}
Slide 91
PRPEARED BY: PROF. NEHA HARDE ©
INPUT OUTPUT FUNCTIONS
Slide 92
PRPEARED BY: PROF. NEHA HARDE ©
FORMAT SPECIFIERS
Slide 93
PRPEARED BY: PROF. NEHA HARDE ©
FORMATED I/O FUNCTIONS
printf()
Syntax:
printf(“Format string”, List of variables);
Example:
printf(“\n Value of a = %d”, a);
Format string can contain:
Characters to print
Conversion specification (%)
Escape Sequences (\)
Slide 94
PRPEARED BY: PROF. NEHA HARDE ©
FORMATED I/O FUNCTIONS
scanf()
Syntax:
scanf(“Format string”, List of addresses of variables);
Example:
scanf(“%d %f %c”, &a, &b, &c);
Format string can contain:
Conversion specification (%)
Slide 95
PRPEARED BY: PROF. NEHA HARDE ©
UNFORMATED I/O FUNCTIONS
Unformatted Input functions
getch():
getch() is used to get a character from the
console but does not echo to the screen
Library: conio.h
Example:
char ch;
ch = getch();
getche():
getche() is used to get a character from the
console and echo to the screen
Library: conio.h
Example:
char ch;
ch = getche();
Slide 96
PRPEARED BY: PROF. NEHA HARDE ©
UNFORMATED I/O FUNCTIONS
Unformatted Input functions
getchar():
getchar() is used to get or read the input
(i.e a single character) at runtime
Library: stdio.h
Example:
char ch;
ch = getchar();
gets():
gets() accepts single or multiple characters
of string including spaces
Library: stdio.h
Example :
char ch[10];
gets(ch);
Slide 97
PRPEARED BY: PROF. NEHA HARDE ©
UNFORMATED I/O FUNCTIONS
Unformatted Output functions
putch():
putch displays any alphanumeric characters to
the standard output device
Syntax:
putch(variable_name);
Example:
char ch = 'a';
putch(ch);
putchar():
putchar() displays any alphanumeric characters
to the standard output device
Syntax:
putchar(variable_name);
Example:
char ch = 'a';
putchar(ch);
Slide 98
PRPEARED BY: PROF. NEHA HARDE ©
UNFORMATED I/O FUNCTIONS
Unformatted Output functions
puts():
puts() displays single or multiple characters of string including spaces to the
standard output device
Syntax:
puts(variable_name);
Example:
char ch[10]="Example";
puts(ch);
Tags
programming
Categories
Technology
Download
Download Slideshow
Get the original presentation file
Quick Actions
Embed
Share
Save
Print
Full
Report
Statistics
Views
80
Slides
98
Age
555 days
Related Slideshows
11
8-top-ai-courses-for-customer-support-representatives-in-2025.pptx
JeroenErne2
48 views
10
7-essential-ai-courses-for-call-center-supervisors-in-2025.pptx
JeroenErne2
47 views
13
25-essential-ai-courses-for-user-support-specialists-in-2025.pptx
JeroenErne2
37 views
11
8-essential-ai-courses-for-insurance-customer-service-representatives-in-2025.pptx
JeroenErne2
35 views
21
Know for Certain
DaveSinNM
23 views
17
PPT OPD LES 3ertt4t4tqqqe23e3e3rq2qq232.pptx
novasedanayoga46
26 views
View More in This Category
Embed Slideshow
Dimensions
Width (px)
Height (px)
Start Page
Which slide to start from (1-98)
Options
Auto-play slides
Show controls
Embed Code
Copy Code
Share Slideshow
Share on Social Media
Share on Facebook
Share on Twitter
Share on LinkedIn
Share via Email
Or copy link
Copy
Report Content
Reason for reporting
*
Select a reason...
Inappropriate content
Copyright violation
Spam or misleading
Offensive or hateful
Privacy violation
Other
Slide number
Leave blank if it applies to the entire slideshow
Additional details
*
Help us understand the problem better