This document provides an overview of input and output in C programming. It discusses how to take input from the keyboard using scanf() and output to the screen using printf(). Specific format specifiers are explained for use in printf() and scanf() functions. Examples are given to demonstrate how to prompt for and read user input with scanf() and then print the output with printf(). It also briefly introduces integrated development environments (IDEs) that can be used for writing and checking C code online.
2. Contents
• Input and Output
• Flow Chart
• Output as printf() function
• Example
• Reading from Keyboard using scanf()
• Example
• IDE and Online code checking
3. Input and Output to a Program/System
In C Programming inside Computer
• Input to a program can be scanned from a keyboard in C
• Output of a C program is taken to the Black screen, Called console
• Enter key( ) is recognized as input completion/terminator (but not always)
In password scanning command, each alphanumeric character (A-z, 0-9, special
characters, etc.) is scanned directly and * is pasted on the console, so it’s a two way
process
C Programming for an Embedded system / controller
• Sometimes Input is read from an electronic port, a button or a switch which uses
a check status function
• Output can also be given to a port, a relay or a socket to run some appliances or
convey messages
5. Input/output in Flowchart
It represents the requirements of a program or displays certain data
• Represented by parallelograms
• indicate an input or output operation
Display message
“How many
hours did you
work?”
Read Hours
6. Printing something on console
printf function is used for printing something on console.
The % sign, also known as format specifier, when used inside a double
quoted string, the variable will appear on this position.
Consequently, %c means that a character will appear here;
For example: displaying a character A should be done as follow.
10. Reading from Keyboard
• scanf function, that is the member of
stdio.h, is used for reading input from
a keyboard in C Programming
• For scanning, we use a & sign with
the variable, that is to be taken from
user
• For printing, only variable name is
used.
#include <stdio.h>
int main()
{
int x;
scanf("%d", &x);
printf("%d", x);
return 0;
}
11. Rules for scanf
• All rules for format specifier are same
• The only difference is that it require input and thus the program waits
for the user to input something.
• A wrong entry causes error which is given by debugger
13. Things to remember about printf and scanf
• printf() is used to display the output
• scanf() is used to read the inputs.
• printf() and scanf() functions are declared in “stdio.h” header file in C
library.
• All syntax in C language including printf() and scanf() functions are
case sensitive.
14. About IDE
• Dev C++ is used which is available in Teams
• Online: https://www.onlinegdb.com/online_c_compiler