- #1
muzihc
- 16
- 0
I'm very new to C. If I had a program like the one below, I was hoping someone could tell me how I should edit it so that the lines "printf("\n%20s%20f", "Half of 1", div1);" and "printf("\n%20s%20f", "Half of 2", div2);" output decimals without too many excess spaces. Currently when outputted, they are in decimal form but don't give remainders and have quite a few zeros. I'm really stuck here and have spent way too much time on this. I'd really appreciate any help.
#include<stdio.h>
int main(void)
{
int int1, int2;
float div1, div2;
printf("\nGive two integers: ");
scanf("%d%d", &int1, &int2);
div1 = int1 / 2
div2 = int2 / 2
printf("\n%20s%20d", "First Number", int1);
printf("\n%20s%20d", "Second Number", int2);
printf("\n%20s%20f", "Half of 1", div1);
printf("\n%20s%20f", "Half of 2", div2);
return 0;
}
#include<stdio.h>
int main(void)
{
int int1, int2;
float div1, div2;
printf("\nGive two integers: ");
scanf("%d%d", &int1, &int2);
div1 = int1 / 2
div2 = int2 / 2
printf("\n%20s%20d", "First Number", int1);
printf("\n%20s%20d", "Second Number", int2);
printf("\n%20s%20f", "Half of 1", div1);
printf("\n%20s%20f", "Half of 2", div2);
return 0;
}