0

code coach halloween coach

in this code #include<stdio.h> int perc(); int main (){ int num_houses; // akes the input scanf("%d",&num_houses); printf("%d%% \n",perc(num_houses)); return 0; } int perc(int house){ int percent=100*2/house; return percent; } when i give 3 it gives 66 but in solo learn code coach it gives 67 and so on when i use round it messes with all the ruslts

25th Nov 2022, 6:37 AM
Shimaa
Shimaa - avatar
1 Antwort
+ 1
Asked to apply round - up so apply ceil function on result. return ceil( 2.0/house * 100 ) ; int/int result int type only. For decimal part, you need atleast on double type value in division.
25th Nov 2022, 8:32 AM
Jayakrishna 🇮🇳