Quote Originally Posted by laserlight View Post
This is the program that I tested:
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;
}
It does not produce the error for me, but according to you, it does. Try it. What error do you get?
I'm extremely sorry, Light. It works for me now. Actually this is what happened. In your first post in this thread you told me to use:
Code:
#define pi 3.142
. I thought you just missed the semicolon at the end out of hurry because you have to help so many people. So, I was using semicolon at the end which gave rise to error. By the way, why don't we use semicolon at the end of it? Please tell me. Thanks a lot.