
September 21st, 2003, 05:12 PM
|
|
Contributing User
|
|
Join Date: Sep 2003
Posts: 53
Time spent in forums: 1 h 10 m 19 sec
Reputation Power: 9
|
|
|
no output code just returns to prompt
I am running some C code on a unix system using a gnut (gcc file.c) compiler and i'm having troubles. The program just returns to prompt without displaying the output.
Code:
#include<stdio.h>
double round (double);
int main(void) {
double orig;
double six;
printf("\nEnter a floating point number to be rounded: ");
scanf("%lf",&orig);
/*+___conversions___+*/
six = (orig * 100000.0 + 0.5)/ 100.0;
printf("\n %lf rounded on the fourth decimal place is %lf.", six, round(orig));
return(0);
}
double round (double num) {
num = (num * 1000.0+0.5)/ 100.0;
return num;
}
I have wasted like hours upon hours trying to figure it out. I have changed things around and fooled with it. It would make sense that the error would be somewhere before the second printf statement but I can't find anything. Please let me know if you find a misstake or if i'm doing something wrong.
-gman932
|