Man. I got my second assignment for programming and it's really frustrating me to no end. I've tried everything I can think of. The assignment should be pretty simple, so I'm kind of embarrassed about posting this, but it's my first time to even look at C coding so I have to start somewhere I guess. Anyway, the assignment is to write a program to take two numbers as input and display their sum, their difference, their product, and their quotient. I am having a problem with decimals and all that though. Here is the code I have so far:
Code:
#include <stdio.h>
#include <conio.h>
int main(void) {
int first, second;
printf("Enter two numbers> ");
scanf("%d %d", &first, &second);
printf("The two numbers are: %d and %d\n", first, second);
printf("Their sum is %.2f\n", first+second);
printf("Their difference is %.2f\n", first-second);
printf("Their product is %.2f\n", first*second);
printf("Their quotient is %.2f\n", first/second);
getch();
}
I know the code is probably horrible, but it's the best I could come up with and it's still not working. I need the input to be able to accept decimals to the hundredths and also the output to display them in the same format.
If there is something obvious that I'm doing wrong, could you please let me know? I'm sure it's something that I overlooked, but it's getting extremely frustrating. Thank you for any help.