Answer the question
In order to leave comments, you need to log in
How to add - 1/3 and 1/5 on s?
I have the following code but it returns null
#include <iostream>
int main()
{
long double a, b, ab;
a = 1 / 3;
b = 1 / 5;
ab = a + b;
printf("%f", ab);
}
Answer the question
In order to leave comments, you need to log in
You are dividing whole numbers.
Try this
#include <iostream>
int main()
{
double a, b, ab;
a = 1.00 / 3.00;
b = 1.00 / 5.00;
ab = a + b;
printf("%f", ab); // 0.53
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question