私はインターネット上でYouTubeとさまざまなガイドを見ていて、多くのことを見ているので電卓を作るのが楽しいと思っていました。それはうまく動作しますが、私はそれも小数を表示できるようにしたい。すべての答えは高く評価されます。したがって、関与なし小数は、(すべての値は切り捨てられます)が存在しない、あなたのすべての計算は整数の数学で行われ私は小数点を表示するにはどうすればいいですか
#include <iostream>
#include <limits>
#include <cstdio>
#include <tchar.h>
#include <conio.h>
using namespace std;
int main()
{
std::cout << "My first caclulator\nPlease enter your first number: ";
int x, y;
std::cin >> x;
std::cout << "Please enter the other number: ";
std::cin >> y;
int w = x*y;
int c = x + y;
int v = x - y;
int q = x/y;
std::cout << "\nNumbers multiplied: " << w << endl;
std::cout << "\nNumbers added together: " << c << endl;
std::cout << "\nNumbers subtracted: " << v << endl;
std::cout << "\nNumbers divided: " << q << endl;
_tprintf(_T("Press any key to exit "));
while (_kbhit()) _gettch();
_gettch();
return 0;
}
「int」と「float」または「double」型の違いについて読んでください。 – DevilaN
あなたのコードは、標準C++の[realmに住んでいません](http://coliru.stacked-crooked.com/a/4ad8de13d5963f13)です。 – user0042