0

Error in the program, it shows no output when i try to run it.

#include <stdio.h> int main() { int n; scanf("%d",n); int p =5; int q = 4; int cost; if(n%2==0) { cost = (n/2)*q; } else { cost = p+((n-1)/2)*q; } printf("%d",cost); return 0; }

22nd Sep 2019, 7:06 AM
Aman Kumar
Aman Kumar - avatar
4 Respuestas
+ 4
Should be: scanf("%d", &n); not scanf("%d", n);
22nd Sep 2019, 7:16 AM
Phurinat Puekkham
Phurinat Puekkham - avatar
0
Thanks @Phurinat, basics really matter.
22nd Sep 2019, 7:47 AM
Aman Kumar
Aman Kumar - avatar