#include <stdio.h>
int main()
{
float a = 19.0;
float b = 5.0;
float floatAnswer;
int x = 19;
int y = 5;
int intAnswer;
floatAnswer = a / b;
printf("%.1f divided by %.1f equals %.1f/n", a, b, floatAnswer);
floatAnswer = x /y; //Take 2 creates an answer of 3.0
printf("%d divided by %d equals %.1f/n", x, y, floatAnswer);
intAnswer = a / b;
printf("%.1f divided by %.1f equals %d/n", a, b, intAnswer);
intAnswer = x % y; // This calculates the remainder (4)
printf("%d modulus (i.e. remainder of) %d equals %d", x, y, intAnswer);
return 0;
}
原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/266777.html