I've tried altering this program a few times... it compiles fine but it crashes when I run it immediately after input. Anyone know what I've done wrong? By the way, I know I could very easily accomplish what this program is designed to do without the convert() function, but I wrote this as an exercise designed to introduce me to using return values of functions.
Code:#include <stdio.h> float convert(void); float dollars; int main(void) { float pounds; printf("Enter a dollar amount: $"); scanf("%f", dollars); pounds = convert(); printf("That's equal to %f pounds!", pounds); return 0; } float convert(void) { return dollars*2; }



1Likes
LinkBack URL
About LinkBacks



