Printf() Function:-
The function is called printf() for a reason. The f stands for formatted. The advantage of the printf function over other, similar display-this-or-that function is C is that the output can be formatted.
I introduce the format for the basic printf function as-
pritnf("text");
But the real format is-
printf("format_string"[,var[,...]]);
What appears in the double quotes is really a formatting string. It’s still text that appears in printf()’s output, but secretly inserted into the text are various conversion characters, or special “placeholders,” that tell the printf() function how to format its output and do other powerful stuff. The printf() function is an important function to show the formatted output on the standard output device such as monitor screen.
The function is called printf() for a reason. The f stands for formatted. The advantage of the printf function over other, similar display-this-or-that function is C is that the output can be formatted.
I introduce the format for the basic printf function as-
pritnf("text");
But the real format is-
printf("format_string"[,var[,...]]);
What appears in the double quotes is really a formatting string. It’s still text that appears in printf()’s output, but secretly inserted into the text are various conversion characters, or special “placeholders,” that tell the printf() function how to format its output and do other powerful stuff. The printf() function is an important function to show the formatted output on the standard output device such as monitor screen.
After the format string comes a comm (still inside the parentheses) and then one or more items called arguments. The argument shown in the preceding example is var, which is short for variable. You can use printf() to display the content or value of one or more variables. You do this by using special conversion characters in format_string.
Syntax:- printf(“format strings”,argument list);
Scanf() Function:-
Output without input is like Desi without Lucy, yang without yin, Caesar salad without the garlic. It means that the seven dwarves would be singing "Oh, Oh, Oh" rather than "I/O, I/O." Besides - and this may be the most horrid aspect of all - without input, the computer just sits there and talks at you. That's just awful.
C has numerous tools for making the computer listen to you. A number of command read input from the keyboard, from commands that scan for individual characters to the vaunted scanf() function, which is used to snatch a string of text form the keyboard and save it in the cuddly, warm paws of a string variable.
Syntax:- scanf("%",&firstname);
Output without input is like Desi without Lucy, yang without yin, Caesar salad without the garlic. It means that the seven dwarves would be singing "Oh, Oh, Oh" rather than "I/O, I/O." Besides - and this may be the most horrid aspect of all - without input, the computer just sits there and talks at you. That's just awful.
C has numerous tools for making the computer listen to you. A number of command read input from the keyboard, from commands that scan for individual characters to the vaunted scanf() function, which is used to snatch a string of text form the keyboard and save it in the cuddly, warm paws of a string variable.
- Scanf() is a function like printf(). Its prpose is to read text from the keyboard.
- Like the f in printf(), the f in scanf() means formatted. you can use fcanf() to read a specifically formatted bit of text from the keyboard. In this chapter, however, you just use scanf() to read a line of text, nothing fancy.
Syntax:- scanf("%",&firstname);
No comments:
Post a Comment