Input and output in C language

Most languages have facilities for input and output ,built into the language. The C language does not have built in statements of I/O. It has function to achieve the I/O .The standard I/O function (scanf(),printf()) are normally performed by using the "stdio.h" header file .It has "conio.h" header file to perform console I/O function (getsl),puts(),getchar,etc.

•Standard input output function.

•scanf()

This function allows to enter data from key board that will be formatted in a certain way. The general form of scanf() Statement is.

scanf() ("formatted string",List of addresses of variables );
For ex-
scanf ("%d%f,"&a,&b);
here & denotes the address of operator , this is necessary because the value received from key board must be dropped into variable corresponding to these address.

%d and %f are formate specifiers which work as conversion characters. Format specifiers used in C are as follows:

Format Specifier              Data type

%d, %i                                       signed integer 
%u                                            unsigned integer
%ld, %li                                    long integer
%lu                                        unsigned long int
%hd, %hi                                short integer
%hu                                     unsigned short int
%f                                                float
%lf,%le,%lg                                 double
%Lf,%Le,%Lg                        long double
%c                                                character
%s                                  string , group of char

•printf()

This function writes formatted data to screen.This function allows to supply the input in a fixed format and to obtain the output in the specified form. The printf() function interprets the contents of the format string.

syntax:
printf("formate string ", variable (if needed));

Ex:
printf("Average =%dpercentage=%f",avg .per);
Here the %d and %f are conversion characters.
They tell printf() to print the value of avg as an integer and per as a float.

 Ex:
printf ("Hello student\nHow\t are \t you");
Here \n,\t are escape sequence .Escape sequence used in C are 

Escape Sequence       Function output

\a                                          beep (alert)
\b                                         back space
\n                                         New line
\t                                           Horizontal tab
\\                                           Back slash
\,                                           Single quote
\\"                                         Double quote
\V                                         Vertical tab
\?                                          Question mark
\0000                           code specified in octal
\xhh               code specified in hexa decimal

•Console I/O Functions

• getch()      Reads a character from key-
                      board
•getche()    Read a character from keyboard
                     and echoes it
•getchar()   Reads a character from keyboar
                      d( macro version)
•gets()          Read a line from keyboard
•putch()      writes a character to the screen
•putchar()   Writes a character to the screen
                       ( micro version).
•puts()           Write a line
•scanf()        Reads formatted data from key
                       board.
•printf()        Writes formatted data to scree 
                         n

__________________The End___________________

               By- Harshit Kumar

                            Admin
:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
If statement/ if -else statement in C

Switch Case Statement in C

Looping statement in C

Comments

Popular posts from this blog

Remove Tools From Termux | How can I reopen the installed tool in termux? | TECH WORTHY MIND

How To Hack Wifi | Hack Wifi Password | TECH WORTH MIND

Best 250+ termux hacking tools