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

  • SEARCH
  • Home
  • 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 8938677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T10:41:06+00:00 2026-06-15T10:41:06+00:00

I saw this below code in an website. I could not able to understsnd

  • 0

I saw this below code in an website.
I could not able to understsnd how the result is coming as 11, instead of 25 or 13.

Why I am thinking 25 because SQ(5) 5*5

or 13 because

SQ(2) = 4;

SQ(3) = 9;

may be final result will be 13 (9 + 4)
But surprised to see result as 11.
How the result is coming as 11?

using namespace std;
#define SQ(a) (a*a)
int main()
{
    int ans = SQ(2 + 3);
    cout << ans << endl;
system("pause");
}
  • 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-06-15T10:41:08+00:00Added an answer on June 15, 2026 at 10:41 am

    #define expansions kick in before the compiler sees the source code. That is why they are called pre-processor directives, the processor here is the compiler that translates C to machine readable code.

    So, this is what the macro pre-processor is passing on to the compiler:

    SQ(2 + 3) is expanded as (2 + 3*2 + 3)

    So, this is really 2 + 6 + 3 = 11.

    How can you make it do what you expect?

    1. Enforce the order of evaluation. Use (), either in the macro definition or in the macro call.
      OR
    2. Write a simple function that does the job
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I saw this on the codeigniter forum Considering the below code UPDATE a INNER
Take the code below, adapted from this question : //Borrowed from another question because
I saw the code below in this answer to What is your favorite C
I once saw this nice little snippet of code below, here at SO: template<typename
I saw a below code: Map(1 -> one, 2 -> two) map _._1 this
I saw this C# using statement in a code example: using StringFormat=System.Drawing.StringFormat; What's that
Comparing the HashMap and Hashtable source code in JDK 1.6, I saw the below
While I was studying assembly code, I saw below code segment. I am a
I have this code below and want it to show the progress of a
The HTML code below consistently results in TEXT A and TEXTB not being horizontally

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.