Top Rated Pune Call Girls Budhwar Peth ⟟ 6297143586 ⟟ Call Me For Genuine Se...
Managing input and output operation in c
1.
2. 1. Introduction
2. Header Files
3. Unformatted input
function
4. Formatted input function
5. Unformatted output
function
6. Formatted output
function
3. Usually higher-level programs
language like C,java,etc..does
not have any build-in
Input/Output statement as
part of syntax.
Therefore we use to file
which has Input/Output
function.
4. Thus, we make header file
which I/O function when it
required.
The value assigned for first time
to any variable is called
initialization.
When we want to use library
functions, it is required to include
respective library in the program.
5. The value assigned for first
time to any variable is called
initialization.
When we want to use library
functions, it is required to
include respective library in the
program.
6. C is functional languages, so
for accepting input and
printing output. There must
provides readymade functions.
Maximum input and output
are define in header files
name in C is stdio.h .
7. Stdio.h (standard input-
output header file) included
function like
get(c),getchar(),gets(),printf()
,put(c),putchar,puts(),scanf(),
etc.
8. Other header files were
1. <ctype.h> :- Character
testing and conversion
function
2. <math.h> :-Mathematical
function
3. <string.h> :-String
manipulation
9. Getchar() function
It is used to accept a
character in a C program.
Its standard form is
Syntax :
variable_name =getchar();
10. Getchar() function
When getchar() function will be
encountered by C compiler while
executing a program , the
program will wait for the user to
press a key from the keyboard.
The character keyword in from
the keyword will be enclose on
the screen.
12. Getch() function
This function is used for
inputting a character from the
keyboard but the character
keyed in will not be enclosed
on the screen. i.e. the
character is invisible on the
screen.
It is included in stdio.h
Header file.
14. Gets() function
This function is used to read
a string from the keyboard if
input device is not specified.
Syntax :
gets(variable_name);
E.g. char str1[50]
gets(str1);
15. Gets() function
When gets() function is
encountered by C compiler, it will
wait for the user to enter sequence
of character from the input device.
The wait gets automatically
terminated when an Enter key is
press.
A null character(‘0’) is
automatically assigned as a last
character of the string by the
compiler immediately after the Enter
key.
16. When formatted input is required :
1. When we need to input numerical
data which may required in
calculations.
2. When enter key itself is a part of
the data.
3. When we need to input data in a
particular format.
The scanf() function is used to input
data in a formatted manner.
17. Scanf() Function
The scanf() function is used to input
data in a formatted manner.
Syntax :
scanf(“control string”,&var1,&var2
,……………,&varn);
In C, to represent an address of any
location , an ampersand(&) is used.
Control string specifies the format
in which the values of variables are
to be stored.
Each format must be preceded by %
sign .
18. Data Type Corresponding Character
For inputting a decimal integer %d OR %i
For inputting an unsigned positive integer %u
For inputting a character %c
For inputting a string %s
For inputting a real value without exponent form %f
For inputting a short integer %h
For inputting a long integer %ld
For inputting a double value %lf
For inputting a long double value %Lf
19. C provides inbuilt function in
library stdio.h know as
printf().
Other for them some
function name putchar() ,
putc() , puts() functions give
the output as it stored in
variable.
20. Putchar() Function
The function putchar() writes a
single character , one at a time
to the standard output device.
Syntax :
putchar(variable_name);
When this statement is
executed , the stored character
will be displayed on the
monitor.
21. Putc() Function
The function putc() send a
character to give file
instead of the standard
output device.
Syntax :
putc(word,file);
22. Puts() Function
The function puts() to write a
string to output device.
Syntax :
puts(variable_name);
Every string contains a null
character but puts() will not
display this character .
23. C provides inbuilt function in
library stdio.h know as printf().
Syntax :
printf(“control string” , var1 ,var2
,……,varn);
The control string entries are
usually separated by space and
preceded by %.
24. Printf() Function
The control string contains two
types object.
1. A set of characters , which will
be display on the monitor as
they come in view.
2. The format specification for
each variable in order in which
they appear.
25. Data Type Corresponding Character
For printing a decimal integer %d
For printing a long decimal integer %ld
For printing a signed decimal integer %i
For printing an unsigned positive integer %u
For printing an integer in octal form %o
For printing an integer in hexadecimal form %x
For printing a character %c
For printing a string %s
For printing a real value without exponent form %f
For printing a real value in exponent form %e
For printing a double value %lf
For printing a long double value %Lf