Program that requests two floating-point numbers and prints the value of their difference divided by their product From what I understand this site help to check if my solution is proper or not..so forgive me if the header is bad.

This is my solution for the question:

#include &lt;stdio.h&gt;

int main()

{

    double num1, num2, different, product, answer;


    printf("please enter 2 floatig point numbers:\n");
    printf("number one is?\n");
    scanf("%lf", &amp;num1);
    printf("number two is?\n");
    scanf("%lf", &amp;num2);


    if (num1 &gt; num2)
    {
        different = num1 - num2;
    }

    if (num2 &gt; num1)

    {
        different = num2 - num1;
    }

    if (num1 == num2)

    {
        different = 0;
    }

    product = num1*num2;

    answer = different/product;

    printf("%lf", answer);


}


How bad is it?
For a newbie, your solution is ok. You can simplify it quite a bit though by using the function fabs. It's a fairly simple function: fabs(x) returns x if x &gt;= 0, and returns -x if x &lt; 0. So all of your if checks can be replaced by the line:

different = fabs(num1 - num2);


Note that you need to #include &lt;math.h&gt; for this.

Also, what happens if one of your numbers is 0? Then your product will also be 0 and your program will crash. It's always a good idea to add some basic checks. Unfortunately, with floating point numbers this can be a bit tricky, so simply doing something like:

if(product == 0.0) { ... }


may not actually work! Fixing this might be a bit tricky for someone who is just learning, but it's something to always keep in mind.

Finally, main should return an int - generally, 0 is what is returned if everything works as it should - so down the bottom should be a return 0;.