Write a C program that reads in two numbers, calculates the modulus of the two and prints out the result. You must use at least three functions (plus main) in your program, however, you must not use return values.
This is the question I have to answer and this is my code so far
Code:
#include <stdio.h>
#include <math.h>
int main()
{
float num1, num2, rem;
printf("First Number?\n");
scanf("%f%",&num1);
printf("Second Number?\n");
scanf("%f",&num2);
rem = fmod(num1,num2);
printf("%.2f divided by %.2f is remainder %.2f\n", num1, num2, rem);
getchar();
return 0;
}
But I have a few problems with it at the moment...
1. I start the program and the message 'First Number?' comes up and I enter a number (lets say 10) but then message 'Second Number?' never appears! If you continue to enter a number (lets say 8), it ends up looking like this
First Number?
10
8
Second Number?
10 divided by 8 is remainder 2
2. At the moment, the program isn't in modular form but how can I use 3 functions for such a small program?
Thanks for any help!