0
Who do this program always output 50 everytime i input 50 and then 100??
#include <stdio.h> int main(){ int una, ikalawa; int marka; int average, score; printf("Enter your score: "); scanf("%d", &una); printf("Enter the number of items: "); scanf("%d", &ikalawa); average = (una/ikalawa) * 50 + 50; printf("%d", average); return 0; }
2 ответов
0
because (una/ikalawa) is result as 0... because 50/100 becomes 0.5 is converted to 0 being both variable are as of int type....
your code should be updated with below:
double perc = (double)una/ ikalawa ;
average = perc * 50 + 50;
0
thank you so much!