[SOLVED] I need help with Halloween Candy. I cannot open from trial 2. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2
20th Apr 2021, 6:56 AM
Sanasam Niranjit Singh
Sanasam Niranjit Singh - avatar
9 Answers
+ 4
You didn't use ceil() function properly. You need to use 200.0 instead of 200 to avoid losing decimals. #include <stdio.h> #include<math.h> int main() { int houses; int num; scanf("%d", &houses); num = ceil(200.0/houses ); //ceil(num); printf ("%d",num); return 0; }
21st Apr 2021, 12:42 AM
Simba
Simba - avatar
+ 2
you have not met the condition for rounding to an integer. your program passes the second test, where the value is an integer. and does not pass the first test, where the value is fractional and the test expects a value of 67, your program outputs an integer value of 66. apply the rounding up function to an integer. Read this in task: "Output Format A percentage value rounded up to the nearest whole number."
20th Apr 2021, 8:10 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 2
Thanks you very much😄😄😄💐💐
20th Apr 2021, 8:16 AM
Sanasam Niranjit Singh
Sanasam Niranjit Singh - avatar
+ 2
Thank you sir💐💐💐💐 U solved my doubt. Thank you very much💞
21st Apr 2021, 1:45 AM
Sanasam Niranjit Singh
Sanasam Niranjit Singh - avatar
+ 1
Hi! what language do you decide in? could you provide us with your code?
20th Apr 2021, 7:44 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
I am writing in c My code is : #include<stdio.h> int main() { int houses, percentage; Scanf(%d,&houses); percentage=200/houses; Printf ("%d", percentage); return 0; }
20th Apr 2021, 7:51 AM
Sanasam Niranjit Singh
Sanasam Niranjit Singh - avatar
+ 1
always read the condition of the task carefully. otherwise, you can miss something important
20th Apr 2021, 8:22 AM
Yaroslav Vernigora
Yaroslav Vernigora - avatar
+ 1
Sir i am stuck again. Is rounding up function in c is ceil. I am using it using math.h header. But result still remains same
20th Apr 2021, 8:24 AM
Sanasam Niranjit Singh
Sanasam Niranjit Singh - avatar
+ 1
This is my new code: #include <stdio.h> #include<math.h> int main() { int houses; int num; scanf("%d", &houses); num = 200/houses ; ceil(num); printf ("%d",num); return 0; }
20th Apr 2021, 8:30 AM
Sanasam Niranjit Singh
Sanasam Niranjit Singh - avatar