What Is scanf() and printf() Function

C functions

C is a functional programming language. C provides library of functions to perform input-output operations. This library is called a standard input-output library. It is denoted by stdio. The header file containing such library functions is called stdio.h. Some standard input-output functions in C are:
  1. printf()
  2. scanf()
  3. gets()
  4. puts()
  5. getch()
  6. getchar()
  7. putchar()
  8. getche()

Mainly there are two types of input-output(I/O) statements:
  1. Formatted I/O statements
  2. Unformatted I/O statements
scanf() and printf() are formatted input and output statements where as getchar(), gets() and putchar(),puts() are unformatted input and output statements.

Lets have a look on Two most widely used INPUT and OUTPUT Functions:

Scanf() Function:
  • To read the values for the variables in a program from the keyboard , C provides a function called scanf(). 
  • It is equivalent to the READ statement. 
  • It is included in stdio.h header file. 
The syntax of scanf() :


  scanf(" control string" , address_list );  


Where
Control string => It is asequence of one or more character group. Each character group is a combination of the % symbol and one of the conversion character. Control string specifies the type of the values which are to be supplied to the variable.
Address_list => Address of the memory location where the value of the input variables should be stored.

NOTE: The character f in the scanf() shows the format(" ") of this function.

Printf() Function:
  • It is used to display the data on the monitor. 
  • It is included in the stdio.h header file. 
The syntax of printf() is:


  printf("Control string" , variable);  


Control string => this specifies the type and format of the values to be displayed.
Variable => list of variables to be displayed.

NOTE: The character f in the printf() shows the format(" ") of this function

Header files:
  • Files that are placed before main() of a C program are called header files. 
  • The header files are used to provide necessary information. 
  • Header files contain library functions. 
  • They can be written with in the angle brackets or the double quotes. 
  • The header files usually contains .h as extension. 
  • They are entered into the source program via #include directive.
Preprocessor directive:
  • C processor is a collection of special statements are called preprocessor directive. 
  • It is executed before the C program is complied. 
  • The preprocessor directive begin with the # symbol and followed by either the include or define keyword. 
  • They are used to include files into a program.
Example:  
#include<stdio.h>
where  #include is a preprocessor directive and <stdio.h> is a header file.


0 Response to "What Is scanf() and printf() Function"

Post a Comment

Popular Posts

Label

1 Sidebar 2 Columns 3 Columns Footer 3rdball 4 Columns Footer Alex Alvaro Antsasia Arlinadesign Averie Barry BASIC CONCEPTS Basil Bayna Fast BeautyPress BeautyTemplates Beckel Best Best - Clean Beyonce Pro BioMag BlackMag Blanter Nova Blogger Card Bloggertheme9 Blogish Bpress Brakt C LANGUAGE C PROGRAMS C++ LANGUAGE C++ PROGRAMS Carella Cellar Charlotte Chooko Lite Clara Clean Combo One Cooperate Crusade Darry Dorman Dreamway Dunia Blanter eCars EduAcademy EducationPress Elise Elvan Eva Everyday FabNews Fashion Fashion Blogger Template Fashion Gossip FastCars Fedo FlashNews Fredy Portfolio Gaming Globus GoodTime Goomsite HTML LANGUAGE iGaming Indicate Innove Insomnia InspiredNews iSoft Jasmine Kalem Landscaping Lashira Lavelle Lily Fashion Limax Linea Lionex Luminescence Lite Lumix Luxury Magazine MagazinePro MAJOR DIFFERENCES MarketingBlog Martin MaxiMag Medica Mega Melissa Mercury MeshMag Minimag Minimalist MiniNews MovieKhor msdesignbd MusicLand Neko NetZine New Spread News16 Newsflash NewsForce NewsIdea Newspaper News NewsPro Nubie Fast Odd Themes Optima PaperMag PaperMag blog Parhlo Perfection Personal Personal Blog Photosout PixelZ Power Blog Premium Themes ProfileMag Purez Rano ReadNews Real estate Remito Grid Responsive Revo Robusta Rotario Saara SeoBoost Settle Shouters Simple Catch SimpleClean Sketchly SNews SolidMag Someo Sophie Sora Sora Bank Sora Home Sora News Responsive Sora One Sora Ribbon Spido Sticko Stucco Sure Mag Swift Tech Tech Pro Techia Techmax TechSpot TemplateClue Templateism Templatesilk Templatesyard Templatezy The Freelancer TheBlogger TheFocus Themeforest Themexpose TIPS AND TRICKS Topside TravelMag Trendy Trendy Travel Tumblr Under Construction Uong Jowo Veethemes Vertox VideoPlay Vigo Waverly way2themes WebBiz Wedding X-Mag Zealer ZetaMag