calclulator

This is a discussion on calclulator within the C++ Programming forums, part of the General Programming Boards category; i have done this code which can do add, sub, mul, div and square. But this much function is not ...

  1. #1
    just a learner |>|?\-/|\/|-])'s Avatar
    Join Date
    Jun 2009
    Location
    IN FRONT OF COMPUTER
    Posts
    19

    calclulator

    i have done this code which can do add, sub, mul, div and square. But this much function is not sufficient for a calculator. I want to add one exponential function and one square root function. plz help me frens
    |>|?\-/|\/|-])-(

  2. #2
    Grey Wizard C_Sparky's Avatar
    Join Date
    Sep 2009
    Posts
    50
    for square root:
    Code:
    {
      double param, result;
      param = 1024.0;
      result = sqrt (param);
      printf ("sqrt(%lf) = %lf\n", param, result );
      return 0;
    }
    Powers:
    Code:
    printf ("7 ^ 3 = %lf\n", pow (7,3));
      printf ("4.73 ^ 12 = %lf\n", pow (4.73,12));
      printf ("32.01 ^ 1.54 = %lf\n", pow (32.01,1.54));
      return 0;
    A simpler version of power:
    Code:
    pow(2, 3); //2 to the 3rd power

  3. #3
    and the hat of wrongness Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    32,452
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.
    I support http://www.ukip.org/ as the first necessary step to a free Europe.

Popular pages Recent additions subscribe to a feed

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21