How to divide 2 int in c?
问题 wanna divide 2 numbers and get the result like this: 5 / 2 = 2.50 But it only outputs 2. I don't now what i'm doing wrong. Here my code: int a; int b; int c; printf("First num\n"); scanf("%d", &a); printf("Second num\n"); scanf("%d", &b); c = a / b; printf("%d", c); 回答1: You need a double variable to store the result. int stores only integers. Additionally, you have to typecast the other variables also before performing the division. Do something like this double c; . . . c = (double)a /