I just wanted to double check some calculations..
My answers are on the right...Is this what the program would return?Code:5 + 3 8 5.6 + 8 13.6 5.3 – 8.7 -3.4 10 / 3 3 17 * 2 3.4 10 / 3.0 3.0 10.0 / 3 3.0 10.0 / 3.0 3.0
I just wanted to double check some calculations..
My answers are on the right...Is this what the program would return?Code:5 + 3 8 5.6 + 8 13.6 5.3 – 8.7 -3.4 10 / 3 3 17 * 2 3.4 10 / 3.0 3.0 10.0 / 3 3.0 10.0 / 3.0 3.0
Last edited by viciousv322; 11-16-2005 at 06:47 PM. Reason: for clarity
No.
Why don't you create a program to do it, and see for yourself?
i keep getting different results... would it matter if the variables were defined as int or double, etc? The problem does not specify??
i got 8, 13, -3, 3 for the first 4...using int... is that correct?
Post your code. Is the code you are running giving expected results or unexpected results? If unexpected, post what result you found was unexpected, and what code produced it.
i guess u are returing int instead of float/double from the fucntion.
you function prototype should look soemthing like this. lets say u function ane us calc
ssharish2005Code:double calc(double);
i guess u are returing int instead of float/double from the fucntion.
you function prototype should look something like this. lets say u function ane us calc
ssharish2005Code:double calc(double);
Code:#include <stdio.h> #define FOO(expr,guess) "%s = %g (%.1f)\n", #expr, expr, guess #define BAR(expr,guess) "%s = %d (%d)\n", #expr, expr, guess #define BAZ(expr,guess) "%s = %d (%.1f)\n", #expr, expr, guess int main(void) { printf(BAR(5 + 3, 8)); printf(FOO(5.6 + 8, 13.6)); printf(FOO(5.3 - 8.7, -3.4)); printf(BAR(10 / 3, 3)); printf(BAZ(17 * 2, 3.4)); printf(FOO(10 / 3.0, 3.0)); printf(FOO(10.0 / 3, 3.0)); printf(FOO(10.0 / 3.0, 3.0)); return 0; } /* my output 5 + 3 = 8 (8) 5.6 + 8 = 13.6 (13.6) 5.3 - 8.7 = -3.4 (-3.4) 10 / 3 = 3 (3) 17 * 2 = 34 (3.4) 10 / 3.0 = 3.33333 (3.0) 10.0 / 3 = 3.33333 (3.0) 10.0 / 3.0 = 3.33333 (3.0) */
7. It is easier to write an incorrect program than understand a correct one.
40. There are two ways to write error-free programs; only the third one works.*
10/3 is...? No, it's not 3.
It is 3 if you are doing integer mathOriginally Posted by Dweia