FYBBA(CA) Sem I
Subject- C Language
Unit -2 Managing I/O operations
Lecture By – Mr. Salunke Ravindra
Head, Department Computer Application,
Dada Patil Mahavidyalaya, Karjat
Lecture - https://youtu.be/pu9ryMfwUMw
1. FYBBA(CA) Sem I
Subject- C Language
Unit -2 Managing I/O operations
Lecture By – Mr. Salunke Ravindra
Head, Department Computer Application,
Dada Patil Mahavidyalaya, Karjat
2. Managing I/O operations
●
Console based I/O and related built-in I/O functions
– printf(), scanf()
– getch(), getchar()
●
Formatted input and formatted output
3. Console Input/Output Functions in C
●
Console : Keyboard and screen together called console.
●
Console I/O functions further classified into:
– Formatted Input/Output Functions
– Unformatted Input/Output Functions
5. C Program to Calculate Simple Interest
Comments in C
Comments are generally used to
increase the readability of program. At
present we are making very small
programs. But when we develop big
programs then the program has to go
through a long process of testing and
debugging. Comments are not the part of
program code and are not read by
compiler.
It is very important to write
comments in programs. So that other
programmers can also read and
understand your program easily. Writing
comments is also a good programming
practice. Start writing comments in the
programs from the beginning itself.
6. Comments in C
1)Single line comment: // first type of comment
2)Multiline comment: /* second type of comment*/
Single line comment is used to write comments in one line only.
Multiline comment is used to write comments in multiple lines. All things that
comes in between /* and */ is considered as comment. We can use anyone according
to requirement.
7. sprintf() and sscanf() Function
sprintf() function is quite similar to printf() function but instead of printing the output on
screen, it stores it in the character array. Consider below example to understand this.
Explanation
As I said earlier sprintf() doesn’t print the output on
screen. So I have printed the value of str using
printf(). It just stores the data in string. In the above
program, str will store the values of “j”, “cha” and “a”.
8. Unformatted Input/Output Functions in C
●
Functions like getch(), getche() and getchar() comes under this category.
●
These functions store only one character.
●
The header file used for these three functions is conio.h
– getch() function-This function is used to store only one character in memory. It
does not echo or display that character on the screen while program execution.
– getche() function-This function works similar to getch function. However it just
echo or display that character on screen.
– getchar() function-This function works entirely similar to getche function. It
stores one character and display it on the screen. But we have to press the enter
key to store one character while using this function.