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...
My First Code:
#include <stdio.h>
#include <conio.h>
void A(int* res)
{
int a,b;
printf("Enter Numbers A: \n");
scanf("%d %d",&a,&b);
*res=a+b;
}
void B(int* res)
{
int a,b;
printf("Enter Numbers B: \n");
scanf("%d %d",&a,&b);
*res=a+b;
}
void main()
{
int total,Ares,Bres;
clrscr();
A(&Ares);
B(&Bres);
total=Ares+Bres;
printf("A + B = %d \n",total);
getch();
}
That works just fine, but with a lower range of numbers
...
So then I tried converting all "int" to "float"
#include <stdio.h>
#include <conio.h>
void A(float* res)
{
float a,b;
printf("Enter Numbers A: \n");
scanf("%.2f %.2f",&a,&b);
*res=a+b;
}
void B(float* res)
{
int a,b;
printf("Enter Numbers B: \n");
scanf("%.2f %.2f",&a,&b);
*res=a+b;
}
void main()
{
float total,Ares,Bres;
clrscr();
A(&Ares);
B(&Bres);
total=Ares+Bres;
printf("A + B = %.2f \n",total);
getch();
}
Then I got an output but is a disaster
Please Help...