printf("ho_tari\n");
genderRatio 본문
#include <stdio.h>
int main(void)
{
int man, woman;
printf("Man: ");
scanf("%d", &man);
printf("Woman: ");
scanf("%d", &woman);
double manratio, womanratio;
manratio = 100.0 * man / (man + woman);
womanratio = 100.0 * woman / (man + woman);
printf("----------------------------\n");
printf("Ratio of Man : %.2f%%\nRatio of Woman : %.2f%%\n", manratio, womanratio);
return 0;
}
#include <stdio.h>
int main(void)
{
int man, woman;
//double man, woman;
printf("input #man #woman : ");
scanf("%d %d", &man, &woman);
//scanf("%lf %lf", &man, &woman);
//double manRatio = 1.0 * man / (man + woman) * 100;
//double womanRatio = 1.0 * woman / (man + woman) * 100;
double manRatio = (double)man / (double)(man + woman) * (double)100;
double womanRatio = (double) woman / (man + woman) * 100;
printf("manRatio: %.2f%%\twomanRatio: %.2f%%\n", manRatio, womanRatio);
return 0;
}
<compile 결과>
'C' 카테고리의 다른 글
incrementor (0) | 2023.09.01 |
---|---|
isAlphabet (0) | 2023.09.01 |
gcd (0) | 2023.09.01 |
findValueInArray (0) | 2023.09.01 |
findValue (0) | 2023.09.01 |