why does different data type b result in different consequence ?
I am a new C++ learner and write a small code. But I am confused the results are different. for example, N N^2 N^2 ----------------------- 0 0 0 5 24 25 10 99 100 Thank you for your patient. #include <iostream> #include <iomanip> #include <cmath> using namespace std; int Square(int); int Cubic(int); int main() { int i, C; cout << " N N^2 N^2" << endl; cout << "-----------------------" << endl; for (i = 0; i <= 10; i++) { C = 5 * i; cout << setw(6) << C << " " << setw(6) << Square(C) << " " << setw(6) << Cubic(C); cout << endl; } cout << "-----------------------" << endl; return 0; } int Square(int c) { int b; b = pow(c, 2); return b; } int Cubic(int c) { float b; b = pow(c, 2); return b; } N N^2 N^2 ----------------------- 0 0 0 5 24 25 10 99 100 15 224 225 20 399 400 25 624 625 30 899 900 35 1225 1225 40 1599 1600 45 2024 2025 50 2499 2500 -----------------------