Thread: problem with simple program

  1. #1
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66

    problem with simple program

    Code:
     
    //this program will calculate the area of a circle.
    #include <iostream>
    #include <iomanip>
    #include <cstdlib>
    using std::cout;
    using std::cin;
    
    
    int main()
        {
              double pi = "3.14";
              double radius = "0.0";
              double area = "0.0";
              
              cout <<"Please enter the radius of a circle: ";
              cin >> radius;
              
              area = pi * radius * radius ; //calculates a circle's area
              
              cout <<"\n\nThe area is: " << area;
              
              cout <<"\n\n";
              system("PAUSE");
              return 0;
        }
    The problem is this:
    Code:
    11 C:\Dev-Cpp\areaOfCircle.cpp cannot convert `const char*' to `double' in initialization
    For the life of me I can't figure out what's wrong.
    Oh my goodness.

  2. #2
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    Get rid of the quotes around your numbers
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

  3. #3
    C++ beginner
    Join Date
    Jun 2004
    Posts
    66
    Quote Originally Posted by JaWiB
    Get rid of the quotes around your numbers
    Boy do I feel stupid. Thank you kindly.
    Oh my goodness.

  4. #4
    chococoder
    Join Date
    Nov 2004
    Posts
    515
    and no, Walmart is not run by fascists.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 03:30 PM
  2. Replies: 1
    Last Post: 12-30-2007, 10:08 AM
  3. Running Program Problem
    By warfang in forum C++ Programming
    Replies: 10
    Last Post: 03-28-2007, 02:02 PM
  4. simple login program problem
    By suckss in forum C Programming
    Replies: 11
    Last Post: 11-11-2006, 05:02 PM
  5. Problem with a simple program
    By Salgat in forum C Programming
    Replies: 10
    Last Post: 06-15-2006, 05:57 PM