Input And Output Statements In C Language

By:


Input : In any programming language input means to feed some data into program. This can be given in the form of file or from command line. C programming language provides a set of built-in functions to read given input and feed it to the program as per requirement.

Output : In any programming language output means to display some data on screen, printer or in any file. C programming language provides a set of built-in functions to output required data.

The functions which are used for inputting and output of C Language are of two types:-

1)Formatted :- Printf() and Scanf

2)Unformatted:- getch(),getche(),getchar(),gets,puts

Printf:-

The printf function has been used widely up to now for output because it provides a neat and easy way of printing text and numbers to stdout (the screen). Its name is meant to signify formatted printing because it gives the user control over how text and numerical data are to be laid out on the screen. Making text look good on screen is important in programming. C makes this easy by allowing you to decide how the text will be printed in the available space. The printf function has general form:
printf ("string...",variables,numbers)

It contains a string (which is not optional) and it contains any number of parameters to follow: one for each blank field in the string.
The blank fields are control sequences which one can put into the string to be filled in with numbers or the contents of variables before the final result is printed out. These fields are introduced by using a % character, followed by some coded information, which says something about the size of the blank space and the type of number or string which will be filled into that space. Often the string is called the control string because it contains these control characters.

Scanf :

Scanf is the input function which gets formatted input from the file stdin (the keyboard). This is a very versatile function but it is also very easy to go wrong with. In fact it is probably the most difficult to understand of all the C standard library functions.
Remember that C treats its keyboard input as a file. This makes quite a difference to the way that scanf works. The actual mechanics of scanf are very similar to those of printf in reverse
scanf ("string...",pointers);
With one important exception: Namely that it is not variables which are listed after the control string, but pointers to variables.


About the Author:
Input : In any programming language input means to feed some data into program. This can be given in the form of file or from command line. C programming language provides a set of built-in functions to read given input and feed it to the program as per requirement.

Output : In any programming language output means to display some data on screen, printer or in any file. C programming language provides a set of built-in functions to output required data.



Article Originally Published On: http://www.articlesnatch.com


|

Loading...
Related....
Videos...

Recent Computers-and-Technology Articles

Comments

Still can't find what you are looking for? Search for it!

Loading

Copyright 2005-2011 ArticleSnatch, LLC - All Rights Reserved.
Privacy Policy | Terms of Service.