Saturday, July 20, 2013

Function doesn't work with float?

Hi there, I'm just new to programming and C++

I have trouble with my code

At first I am using "int" for variables but then I realize that i need a much larger range of numbers and also support for decimal operations so I change all "int" to "float"...


Code:



#include #include void A(floatprintf("Enter Numbers A: n"); scanf("%.2f %.2f",&a,res=a+b; } void B(floatprintf("Enter Numbers B: n"); scanf("%.2f %.2f",&a,res=a+b; } void main() { float total,Ares,Bres; clrscr(); A(Ares); B(Bres); total=Ares+Bres; printf("A + B = %.2f n",total); getch(); }



There's no error in compiling, but output is a disaster.. :(
Full Post

No comments:

Post a Comment