Please check my code

Pages: 12
Thanks guys. A lot. I will make some improvements to my calculator. And @JLBorges I don't understand why you don't use "using namespace std;" and why so many functions. Also why using constants. Also the code is just weird for me and some things I don't understand like std::fixed. Thanks though.
> I don't understand why you don't use "using namespace std;"

See: http://www.cplusplus.com/forum/general/72248/#msg385442


> why so many functions.

See: http://www.cplusplus.com/forum/general/188651/#msg915778


> Also why using constants.

See: http://www.cplusplus.com/forum/beginner/180986/#msg888218


> I don't understand like std::fixed

1
2
3
4
5
6
7
8
9
10
11
12
13
#include <iostream>
#include <iomanip>

int main()
{
    const double a = 7.0 ;
    const double b = 12345657.897 ;

    std::cout << a << ' ' << b << '\n'  // default: 7 1.23457e+07
              << std::scientific << a << ' ' << b << '\n' // scientific: 7.000000e+00 1.234566e+07
              << std::fixed << a << ' ' << b << '\n' // fixed, default precision: 7.000000 12345657.897000
              << std::setprecision(2) << a << ' ' << b << '\n' ; // fixed, 2 digits after decimal point: 7.00 12345657.90
}

http://coliru.stacked-crooked.com/a/f511ebfa6733d94c
Last edited on
Topic archived. No new replies allowed.
Pages: 12