Feedback for SUGARCANE problem

Problem Link: SUGARCANE Problem - CodeChef

so the question says that 20% in sugercane purchase,20% more in salt and stuff and 30%percent for rent
the isnt it clear that 20+20+30 =70 percent goes in stuff and only 30 percent of his income is left as the profit
for is the total cost a glass is 50 rupees and he sells β€˜n’ glasses a day the
would profit not be 30% of his total income??
and if i write code similar to my logic it always prints 0 0 0 0 or 1 1 1 1

my code is as below

include <stdio.h>

int main(void) {
int t,n;
scanf(β€œ%d”,&t);
while(t–){
scanf(β€œ%d”,&n);
printf(β€œ%d\n”,n50(30/100));
}
return 0;
}

The mistake is in the printf statement. You just wrote n50(30/100). You intention is to multiply. Mathematically it works. But in programming it is mandatory to mention the * symbol. Don’t worry I made the same exact mistake too when I started out :joy:
Here is the modified code.

#include <stdio.h>

int main(void)
{
    int t, n;
    scanf("%d", &t);
    while (t--)
    {
        scanf("%d", &n);
        printf("%d\n", n * 50 * 30 / 100);
    }
    return 0;
}

And i don’t know you wrote t-- or just t-. If you wrote t- then it should be t --.

1 Like