Thread: learning to use #define

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Mar 2011
    Posts
    254

    learning to use #define

    Hi

    My elementary programming skills which I acquired not long ago are very much rusty these days. I was practicing with the code below but I received those two errors about the line at #17 in the source code. Would you please help me?

    I remember when I started posting here people would tell me that my code isn't properly organized, like braces are not aligned etc. They used to use a certain term. What is it? Please tell me. Thank you for all the help.

    Code:
    //define_pi.cpp
    // learning to use #define on Pi
    
    #include <iostream>
    #include <cstdlib>
    #include <cmath>
    
    using namespace std;
    
    int main()
    {
        float r, area;
        #define pi = 3.142;
    
        cout << "enter radius"; cin >> r;
    
        area = 2*pi*r;
    
        cout << "area is: " << area << endl;
    
        system("pause");
        return 0;
    }
    Errors:
    Code:
    17|error: expected primary-expression before '=' token|
    17|error: invalid type argument of 'unary *'|
    Last edited by jackson6612; 09-20-2011 at 10:21 AM.
    I'm an outright beginner. Using Win XP Pro and Code::Blocks. Be nice to me, please.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. #define
    By Johnathan1707 in forum C Programming
    Replies: 3
    Last Post: 08-02-2009, 09:10 AM
  2. difference between #define and #define ()
    By bored_guy in forum C Programming
    Replies: 8
    Last Post: 07-20-2009, 06:58 PM
  3. #define
    By tikelele in forum C Programming
    Replies: 2
    Last Post: 12-01-2007, 11:43 PM
  4. Learning Dos and learning Windows
    By blankstare77 in forum C++ Programming
    Replies: 8
    Last Post: 07-31-2005, 03:48 PM