OP: plenty of help on the web eg.
http://linux.die.net/man/3/printf

Something else you could consider is using just integers to hold your
values to avoid the errors you get with floating point arithmetic and
decimal fractions (such as 1244*40/100 = 497.600006, not 497.6):

#include <stdio.h>

int main(void)
{
    long da_c, hr_c, i;

    printf(" Enter Basic Salary = " );
    scanf("%ld", &i);

    da_c = i * 40; /* calculate in cents */
    hr_c = i * 20;

    printf("DA = %ld.%02ld and HR = %ld.%02ld\n",
        da_c / 100, da_c % 100,
        hr_c / 100, hr_c % 100);

    return 0;
}

It's best to use long to try to avoid arithmetic overflows, which are
more likely when using integer arithmetic.

Reply via email to