This is question #8 from chapter 5 in Sams teach yourself c programming in 21 days:
8. Write a function that receives two numbers as arguments. The function
should divide the first number by the second. Don't divide by the second
number if it's zero. (Hint: Use an if statement.)
Anyways when I execute it, I enter one number and it goes straight to "Hit any key to..." how do I stop this, it has never happened before and I know this should be an easy question but still I would appreciate a little help thanks in advanceCode:#include <stdio.h> float a,b,c=0; float divide(float c,float d); int main(void) { printf("Please enter two numerical values(deciamals are accepted): "); scanf("%f,%f",&a,&b); float divide(float c,float d); c=float divide(float c, float d); printf("Answer: %d", c); return 0; } float divide(float c, float d) { float e=0; if(d>0) e=c/d; else void; return e; }
P.S. The only error it has is: (16) : error C2062: type 'float' unexpected, how exactly do I go about fixing that, because it is already declared as a float...



LinkBack URL
About LinkBacks




) I will probably try your "later lesson" way, thanks Prelude
, but that is for a "later time" right 