C

printf width & precision (%5d, %.2f)

Në shqip: Gjerësia dhe saktësia te printf

ShpjegimiSQ

Te printf, numrat para shkronjës kontrollojnë pamjen: %5d rezervon 5 vende, %-10s e shtyn tekstin majtas, %.2f shfaq dy shifra pas presjes, %05d mbush me zero. Ideal për tabela.

EnglishEN

In printf, numbers before the letter control the look: %5d reserves 5 places, %-10s left-aligns text, %.2f shows two decimals, %05d pads with zeros. Ideal for tables.

Si ta mendosh

Si kolonat e vizatuara në fletoren e matematikës.

Lexoje në anglisht

Like the ruled columns in a maths notebook.

Shembull kodic

printf("%-10s|%5d|%8.2f\n", "Arta", 5, 4.756);
printf("%05d\n", 42);   // 00042

Terma të lidhur