constant defined using connst int and #define

Discussion in 'C Programming' started by prati, Oct 27, 2012.

  1. prati

    prati

    Joined:
    Aug 2, 2012
    Messages:
    7
    Suppose i have defined a constant as const int MAX =5 and i am using it in a function called find().


    void find()
    {

    if(MAX==5)
    {
    //do this
    }
    else
    {
    //do this
    }
    }

    if i am calling this function for 100 of times then which way is better to define a constant as i can define a constant in 2 ways.
    1 const int MAX=5
    2.#define MAX 5
    prati, Oct 27, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Christopher M. Lusardi
    Replies:
    1
    Views:
    4,074
  2. Schnoffos
    Replies:
    2
    Views:
    1,199
    Martien Verbruggen
    Jun 27, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    1,617
    Old Wolf
    Jan 20, 2004
  4. Oodini
    Replies:
    1
    Views:
    1,754
    Keith Thompson
    Sep 27, 2005
  5. ThazKool
    Replies:
    1
    Views:
    437
    sandravandale@yahoo.com
    Jun 11, 2006
Loading...

Share This Page