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
    Likes Received:
    0
    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. Advertisements

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,361
  2. Schnoffos
    Replies:
    2
    Views:
    1,489
    Martien Verbruggen
    Jun 27, 2003
  3. Hal Styli
    Replies:
    14
    Views:
    2,061
    Old Wolf
    Jan 20, 2004
  4. Oodini
    Replies:
    1
    Views:
    2,066
    Keith Thompson
    Sep 27, 2005
  5. arun
    Replies:
    8
    Views:
    722
    Dave Thompson
    Jul 31, 2006
  6. aling
    Replies:
    8
    Views:
    1,736
    Jim Langston
    Oct 20, 2005
  7. ThazKool
    Replies:
    1
    Views:
    591
    sandravandale@yahoo.com
    Jun 11, 2006
  8. haijin.biz@gmail.com
    Replies:
    9
    Views:
    649
    James Kanze
    Apr 17, 2007
Loading...