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 4022732
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T10:30:44+00:00 2026-05-20T10:30:44+00:00

I am trying to solve two Preprocessor related questions but in both programs I

  • 0

I am trying to solve two Preprocessor related questions but in both programs I am getting results that I am not able to figure out how. Below is my program:

#include<stdio.h>
#define SQUARE(x) x*x
int main()
{
float s=10,u=30 ,t=2,a;
a=2*(s-u*t)/SQUARE(t);
printf("Result:%f\n",a);
return 0;
}

According to me, the output of this programme should be -25.000 but I am getting -100.000.

And in second program:

#define FUN(i,j) i##j
int main()
{
int val1 = 10;
int val12 = 20;
clrscr();
printf("%d\n",FUN(val1,2));
getch();
}

Output should be 102 but I am getting 20;
why is it so?

  • 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-20T10:30:45+00:00Added an answer on May 20, 2026 at 10:30 am

    the first one:

    a=2*(s-u*t)/SQUARE(t);
    

    after replacing the define we get:

    a=2*(s-u*t)/t*t;
    

    now, since we don’t have () in the definition of SQUARE we get:

    a=2*(10-30*2)/2*2; --> a=2*(-50)/2*2; --> a=-100/2*2; --> a=-50*2; --> a=-100
    

    if you want to get -25 you should define SQUARE(x) as (x*x).

    Edit : add explanation regarding the second example.

    printf("%d\n"FUN(val1,2));
    

    once again, we first should replace the define (reminder: ## “concatenates” the string of the define – I can’t find the perfect words in order to explain it so just take a look at the example…):

    printf("%d\n",val12);  [note: the comma (,) is missing - so it won't compile.]
    

    since the value of val12 is 20 that’s what you’ll get.

    the point of those 2 examples is to remember that we should always deal with the defines first (since in “real life” the compiler (or pre-processor) does it before the run time)

    I hope it helps..

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

Sidebar

Related Questions

A problem I'm trying to solve: given that you have two distinct strings composed
I've been trying to solve these problem for last two hours but seems like
I am trying to solve the question below, but I do not understand it
Trying to solve a problem with templatetags. I have two templatetags: @register.inclusion_tag('directory/_alphabet.html') def alphabet_list(names):
I'm trying to solve the 3n+1 problem and I have a for loop that
While trying to solve a two-way data binding problem in here , I found
I'm trying to solve a gitignore problem on a large directory structure, but to
i'm trying to solve a seemingly simple problem, but just can't quite get my
I am trying to solve Euler's Project #2 and I keep getting the answer
Using six-bit one's and two's complement representation I am trying to solve the following

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.