Formatted IO - Programming Tutorials

Programming Tutorials

Programming Tutorials

Ads Here

Formatted IO

4.1.1 Formatted Output - printf It takes text and values from within the program and sends it out onto the screen. printf(''%f is your weight\n'', w); In the above program statement: ''%f is your weight\n'' is the control string w is the variable to be printed %f meaning that a floating point value is to be printed. The number of conversion specifications and the number of variables following the control string must be same, and that the conversion character is correct for the type of the parameter. 4.1.2 Formatted Input - scanf scanf is used to get input from user and to store it in the specified variable(s). scanf(''%d'', &x); read a decimal integer from the keyboard and store the value in the memory address of the variable x. 4.1.3 Character Escape Sequences There are several character escape sequences which can be used in place of a character constant or within a string. \a alert (bell) \b backspace \f formfeed \n newline \r carriage return \t tab \v vertical tab \ backslash \? question mark \' quote \'' double quote \ooo character specified as an octal number \xhh character specified in hexadecimal

No comments:

Post a Comment