C++ đây là lỗi gì vậy mọi người. Tại sao
45,5 + 45,5 = 90
hoặc
123,456 / 654,321 = 0,188073
Nó nên là 123,456 / 654,321 = 0,1886780342 (bên phải)
main.cpp
#include <iostream>
#include "add.h"
int main()
{
using namespace std;
float x = enterNumber();
float y = enterNumber();
summation(x+y);
cin.get();
return 0;
}
add.cpp
#include <iostream>
#include <iomanip>
int enterNumber()
{
using namespace std;
float x;
cout << "Enter any number" << endl;
cin >> x;
cin.get();
return (x);
}
void summation(float x)
{
using namespace std;
cout << "Results returned :" << x << endl;
}
add.h
#ifndef ADD_H
#define ADD_H
int enterNumber();
void summation(float x);
#endif
. Mình đã từng bị một lần mày mò cả buổi mới nhận ra giờ thì có lẽ nhớ hết đời luôn
.
83% thành viên diễn đàn không hỏi bài tập, còn bạn thì sao?