C Programming input output
C programming Input & Output
This tutorial focuses on two in-built functions printf() and scanf() to perform I/O task in C
programming. Also, you will learn to write a valid program in C.
Two commonly used functions for I/O (Input/Output) are printf() and scanf().
The scanf() function reads formatted input from standard input (keyboard) whereas the
Example Of Input & Output :
#include <stdio.h> //This is needed to run printf() function.
int main()
{
printf("C Programming");//displays the content inside quotation
return 0;
}
Output:
C Programming
The Standard Files :
C programming treats all the devices as files. So devices such as the display
are addressed in the same way as files and the following three files are
automatically opened when a program executes to provide access to the keyboard and screen.
The scanf() and printf() Functions :
The int scanf(const char *format, ...) function reads the input from the
standard input stream stdin and scans that input according to the format
The int printf(const char *format, ...) function writes the output to the
standard output stream stdout and produces the output according to the format provided.
The format can be a simple constant string, but you can specify %s, %d, %c, %f, etc.,
to print or read strings, integer, character or float respectively.
There are many other formatting options available which can be used based on requirements.
Comments
Post a Comment