Upload
hanielle-cheng
View
478
Download
0
Embed Size (px)
DESCRIPTION
Citation preview
Free Powerpoint TemplatesFree Powerpoint TemplatesARVINsantosbuendia
Free Powerpoint Templates
OBJECTIVES
Take Quiz 01
Explain Format Specifier
Enumerate the Different Format Specifier in Turbo-C
Evaluate Format Specifier
Free Powerpoint Templates
SCREEN OUTPUT AND ESCAPE SEQUENCEprintf(“samahan mo \\akong\\ pa-blood\n”);
printf(“test… \n\nbaket???”);printf(“\t\npara malaman \nmo ikaw \tang \”type ko\””);
samahan mo_ _\ akong _\ _pa-blood__test…
___baket???_ _
_para malaman _
_mo ikaw _ _ang _“type ko_“_
_
Free Powerpoint Templates
FORMAT SPECIFIERS
FORMAT SPECIFIERS starts with a percent sign % followed by a character that specified the format type
printf(“ twenty five %d”, <argument list>)
FORMAT SPECIFIERS
%c a single character%s string of charcters%i or %d integer number%f floating point%% prints a percent sign
FORMAT SPECIFIERFORMAT TYPE
Free Powerpoint Templates
FORMAT SPECIFIERS
FORMAT SPECIFIER %cprintf(“charcater %c\n”, ‘a’);
printf(“character %c”, ‘5’);FORMAT TYPE
ARGUMENT LIST
_
character a_
_
character
_
5_
Free Powerpoint Templates
FORMAT SPECIFIERS
FORMAT SPECIFIER %sprintf(“string is %s\n”, ”SUPERman” );
FORMAT SPECIFIER FORMAT TYPE
ARGUMENT LIST
_
string is
_
SUPERman__
Free Powerpoint Templates
FORMAT SPECIFIERS
FORMAT SPECIFIER %i or %dprintf(“integer %i\n”, 5);
printf(“integer %d”, 25);
FORMAT SPECIFIER
ARGUMENT LIST
_integer _5__integer _25_
FORMAT TYPE
Free Powerpoint Templates
FORMAT SPECIFIERS
FORMAT SPECIFIER %fprintf(“float %f\n”, 5.3);
printf(“float with two decimal places %.2f”, 5.345 );
FORMAT SPECIFIER FORMAT TYPEARGUMENT LIST
_float _5.300000__float with two decimal places _5.35_
NUMBER OF DECIMAL
Free Powerpoint Templates
FORMAT SPECIFIERS
FORMAT SPECIFIER %%printf(“Printing percent %%\n”);FORMAT SPECIFIER FORMAT TYPE
_Printing percent _%__
Free Powerpoint Templates
FORMAT SPECIFIERS<argument list> contains exactly the same number of arguments as there are format specifiers, and the format specifiers and argument list are matched in order
printf(“Product of 5 and 25 is %i\n”,5 * 25);printf(“Product of %d and %d is %i”, 5, 25, 5 * 25);
_Product of 5 and 25 is
_125
_
_Product of _5 _and _25 _is _125_
Free Powerpoint Templates
FORMAT SPECIFIERS
If the item of data type that does not directly correspond to the format specification, you will get unpredictable result
printf(“integer %f”, 2);
Abnormal program termination
printf(“My name is %d”, ”ARVIN”);
_My name is _419_