Formatted Input/Output
-SHOVAKHAR BHANDARI
These are the functions to receive input from
keyboard and write output to VDU.
◦ These are divided into two catogories:
Formatted functions.
-Formatted output converts the internal binary
representation of the data to ASCII characters
which are written to the output file.
-printf() and scanf() are examples for
formatted input and output function.
Unformatted functions.
-Unformatted input/output transfers the internal
binary representation of the data directly between
memory and the file.
- getch(), getche(), getchar(),
gets(), puts(), putchar() etc. are
examples of unformatted input output
functions
CONSOLE I/O
Formatted output:
The function printf() is used for formatted output to standard output based on a format
specification.
Syntax:
printf (format_string, list_of_expressions);
where:
•format_string is the layout of what's being printed
•list_of_expressions is a comma-separated list of variables or expressions yielding results to be
inserted into the output
Formatted input:
•To read data in from standard input (keyboard), we call the scanf function. The basic form of a
call to scanf is:
• scanf(format_string, list_of_variable_addresses);
The Format specifier is a string used in the formatted input and output functions.
The format string determines the format of the input and output.
 The format string always
starts with a '%' character.
Example:
In the given example :
Scanf and printf are formatted
functions and “%d” “%f” are
Format specifier.
FORMAT SPECIFIER
#include<stdio.h>
int main(){
int a;
float b;
printf("Enter the value of a and b");
scanf("%d %f",&a,&b);
printf("THe value of a and b are %d and %f
respectively",a,b);
return 0; }
FORMAT SPECIFIER
DATA TYPE MODIFIERS
The prefix used in data-type to modify (either increase or decrease) the amount of storage
space allocated to a variable are data type modifiers.
For example, storage space for int data type is 4 byte for 32 bit processor. We can
increase the range by using long int which is 8 byte. We can decrease the range by using
short int which is 2 byte.
1. Long-used to store very large number.
2. Short- limits user to store small integer values from -32768 to 32767.
3. Signed-user can store both negative and positive values.
4. Unsigned - store only positive values.
RELATED QUESTIONS
1. What are formatted I/O functions?
2. Differentiate between formatted and unformatted functions.
3. What is the difference between Character, Integer, Float and Double data types.
REFRENCES
1. Let us c 14th edition.
2. https://www.c-sharpcorner.com/UploadFile/a5f59f/using-formatted-io-input-
output-functions-with-example-in/

c program presentation on format specifer.pptx

  • 1.
  • 2.
    These are thefunctions to receive input from keyboard and write output to VDU. ◦ These are divided into two catogories: Formatted functions. -Formatted output converts the internal binary representation of the data to ASCII characters which are written to the output file. -printf() and scanf() are examples for formatted input and output function. Unformatted functions. -Unformatted input/output transfers the internal binary representation of the data directly between memory and the file. - getch(), getche(), getchar(), gets(), puts(), putchar() etc. are examples of unformatted input output functions CONSOLE I/O
  • 3.
    Formatted output: The functionprintf() is used for formatted output to standard output based on a format specification. Syntax: printf (format_string, list_of_expressions); where: •format_string is the layout of what's being printed •list_of_expressions is a comma-separated list of variables or expressions yielding results to be inserted into the output Formatted input: •To read data in from standard input (keyboard), we call the scanf function. The basic form of a call to scanf is: • scanf(format_string, list_of_variable_addresses);
  • 4.
    The Format specifieris a string used in the formatted input and output functions. The format string determines the format of the input and output.  The format string always starts with a '%' character. Example: In the given example : Scanf and printf are formatted functions and “%d” “%f” are Format specifier. FORMAT SPECIFIER #include<stdio.h> int main(){ int a; float b; printf("Enter the value of a and b"); scanf("%d %f",&a,&b); printf("THe value of a and b are %d and %f respectively",a,b); return 0; }
  • 5.
  • 6.
    DATA TYPE MODIFIERS Theprefix used in data-type to modify (either increase or decrease) the amount of storage space allocated to a variable are data type modifiers. For example, storage space for int data type is 4 byte for 32 bit processor. We can increase the range by using long int which is 8 byte. We can decrease the range by using short int which is 2 byte. 1. Long-used to store very large number. 2. Short- limits user to store small integer values from -32768 to 32767. 3. Signed-user can store both negative and positive values. 4. Unsigned - store only positive values.
  • 7.
    RELATED QUESTIONS 1. Whatare formatted I/O functions? 2. Differentiate between formatted and unformatted functions. 3. What is the difference between Character, Integer, Float and Double data types.
  • 8.
    REFRENCES 1. Let usc 14th edition. 2. https://www.c-sharpcorner.com/UploadFile/a5f59f/using-formatted-io-input- output-functions-with-example-in/