Basic input question

This is a discussion on Basic input question within the C++ Programming forums, part of the General Programming Boards category; I'm just starting so excuse my ignorance. anyway, I'm trying to write a simple math program which computes the value ...

  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    1

    Basic input question

    I'm just starting so excuse my ignorance. anyway, I'm trying to write a simple math program which computes the value of a trigonometric function. Basically just input one value and get another out, but I have two problems:
    1. even with cmath included, the constant pi is not provided(I tried PI)
    2. I can't seem to input values in the form of division ie 1/2, pi/3. I declared the input variable type double so does that mean you can't enter fractions during cin?

    btw, I'm using Dev C++ V4.9.9.2

  2. #2
    Programming King Mr.777's Avatar
    Join Date
    Mar 2011
    Location
    Middle of NoWhere
    Posts
    320
    1. even with cmath included, the constant pi is not provided(I tried PI)
    do
    Code:
    const double PI=3.141414;
    2. I can't seem to input values in the form of division ie 1/2, pi/3. I declared the input variable type double so does that mean you can't enter fractions during cin?
    Study about classes, overloading, and operators overloading.....

  3. #3
    Jack of many languages Dino's Avatar
    Join Date
    Nov 2007
    Location
    Katy, Texas
    Posts
    2,309
    For PI, include <math.h> and reference M_PI.

    You won't be able to input fractions and have the expression evaluated as part of the cin processing. Doesn't work that way.
    Mac and Windows cross platform programmer. Ruby lover.

    Quote of the Day
    12/20: Mario F.:I never was, am not, and never will be, one to shut up in the face of something I think is fundamentally wrong.

    Amen brother!

  4. #4
    Registered User bobknows's Avatar
    Join Date
    Jan 2011
    Location
    SD
    Posts
    87
    if you input the fraction as a string you can, but there are no spaces and you have to convert it yourself. if you input it as an int/float/double it will read up to the first non-numerical character.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Arrow keys and normal input question
    By edomingox in forum Game Programming
    Replies: 7
    Last Post: 12-04-2010, 08:55 PM
  2. Replies: 11
    Last Post: 12-08-2009, 02:04 PM
  3. CIN Input count question?
    By kamran in forum C++ Programming
    Replies: 5
    Last Post: 10-24-2006, 04:06 PM
  4. Structure and Linked List User Input Question
    By kevndale79 in forum C Programming
    Replies: 16
    Last Post: 10-05-2006, 11:09 AM
  5. fstream char array input question
    By mcdms in forum C++ Programming
    Replies: 6
    Last Post: 12-07-2004, 09:40 PM

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