EmbLogic's Blog

How this output come??? 09/06/12

#include

int main()
{
std::printf(“Strings:\n”);
const char* s = “Hello”;
std::printf(“\t.%10s.\n\t.%-10s.\n\t.%*s.\n”, s, s, 10, s);

std::printf(“Characters:\t%c %%\n”, 65);

std::printf(“Integers\n”);
std::printf(“Decimal:\t%i %d %.6i %i %.0i %+i %u\n”, 1, 2, 3, 0, 0, 4, -1);
std::printf(“Hexadecimal:\t%x %x %X %#x\n”, 5, 10, 10, 6);
std::printf(“Octal:\t%o %#o %#o\n”, 10, 10, 4);

std::printf(“Floating point\n”);
std::printf(“Rounding:\t%f %.0f %.32f\n”, 1.5, 1.5, 1.3);
std::printf(“Padding:\t%05.2f %.2f %5.2f\n”, 1.5, 1.5, 1.5);
std::printf(“Scientific:\t%E %e\n”, 1.5, 1.5);
std::printf(“Hexadecimal:\t%a %A\n”, 1.5, 1.5);
}

Output:

Strings:
. Hello.
.Hello .
. Hello.
Characters: A %
Integers
Decimal: 1 2 000003 0 +4 4294967295
Hexadecimal: 5 a A 0×6
Octal: 12 012 04
Floating point
Rounding: 1.500000 2 1.30000000000000004440892098500626
Padding: 01.50 1.50 1.50
Scientific: 1.500000E+00 1.500000e+00
Hexadecimal: 0×1.8p+0 0X1.8P+0

Also , the %g operator strips off all the precision digits.
working of sizeof((int),float))
working of printf(“%o”,sizeof(sizeof(5.0)))

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>