Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6755961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:27:57+00:00 2026-05-26T13:27:57+00:00

here C programming Guidelines and coding standards says we have to avoid magic numbers

  • 0

here C programming Guidelines and coding standards says we have to avoid magic numbers from program and use macro for magic numbers

In Macro it will take more time to evaluate as compare to Constants so performance is more better in magic numbers or constants.

for Example

for(i=0;i<255;i++)
{

} 

We use this

#define MAX 255

for(i=0;i<MAX;i++)
{

}

Second one is take more time compare to first one so why we prefer second one as per coding standards.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T13:27:57+00:00Added an answer on May 26, 2026 at 1:27 pm

    using a macro constant doesn’t take more time. the #define is a preprocessor instruction, so in the binary code, the two pieces of code will compile to the same thing!

    However, we avoid using ‘magic numbers’ for reasons of maintainability, assume you have many loops and arrays of the same size, if this size changes in the future, you will need to search the code and change it everywhere, [and only it!] while if you use a preprocessor command, you will need to change only it [the preprocessor command].

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to implement quicksort. From Programming Pearls here is the code: public class
Here is a challenge question I've got from Linux system programming lecture. Any of
Here is a sample from Kernighan & Ritchie's The C Programming Language: int getline(char
I'm programming in C here, for Windows and various Unix platforms. I have a
I've seen here that what sets a programming language apart from a scripting language
hello I am new here and in programming as well. Today I have been
Here's my problem (I'm programming in C): I have some huge text files containing
Not quite programming, but someone here will know what I'm talking about and didn't
Here's a question where my real world programming inexperience shines through. I have a
I am rather new to socket programming but here goes nothing. I have been

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.