Thread: Basic input question

  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
    Chappell Hill, Texas
    Posts
    2,332
    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.
    Mainframe assembler programmer by trade. C coder when I can.

  4. #4
    Registered User
    Join Date
    Jan 2011
    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, 09:55 PM
  2. Replies: 11
    Last Post: 12-08-2009, 03: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, 10:40 PM