How to divide 2 int in c?

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 / (double)b;
printf("%f", c);

NOTE:

You do not need the & in printf() statements.

Leave a Comment