Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > General Computer Discussion > Software > constant defined using connst int and #define

Reply
Thread Tools

constant defined using connst int and #define

 
 
prati prati is offline
Junior Member
Join Date: Aug 2012
Posts: 8
 
      10-27-2012
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
constant defined using connst int and #define prati C Programming 0 10-27-2012 03:45 PM
Difference between int i, j; and int i; int j; arun C Programming 8 07-31-2006 05:11 AM
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) Oodini C Programming 1 09-27-2005 07:58 PM
int main(int argc, char *argv[] ) vs int main(int argc, char **argv ) Hal Styli C Programming 14 01-20-2004 10:00 PM
dirty stuff: f(int,int) cast to f(struct{int,int}) Schnoffos C Programming 2 06-27-2003 03:13 AM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57