Adding real numbers

Ok hi guys, just started electrical engineering a few days ago, and c++ programming is a part of the degree, and i need some help with it lol

i made a code, that asks the user for 2 numbers and then divides them, adds them, and multiplie them.

but when it divides them, it dosent give me a real numbers, it dosent give me 1.2 for example.

what do i have to do so it would?
my english isnt the best so if you can try and use simple phrases i would appreciate it :)

thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
 #include <iostream>
#include <cmath>
using namespace std;

int main()
{
	cout << "Enter any two numbers, young mathematician"; cout << endl;

	int a;
	int b;
	cin >> a; cout << endl;
	cin >> b; cout << endl;
	cout << "The sum of those two numbers are:" << endl << a + b << endl;
	cout << "Their division is:" << endl << a / b << endl;
	cout << "Their difference is:" << endl << a - b << endl;
	cout << "Their multipication is:" << endl << a*b << endl;
	cout << endl;
	return 0;
} Put the code you need help with here.
int will only give you integers ex. 1,2,3,4.. etc. You can use double
Last edited on
So i need to write double, insted of int?
Yes, double can print up to 15 digits
Last edited on
thank ye so much :)
worked
Topic archived. No new replies allowed.