#include <stdio.h>
#define sqr(x) (x*x)
int main()
{
int x=2;
printf("value of x=%d",sqr(x+1));
}

What is the value of x?

Answer Posted / jugal

The OUTPUT of the program wud be
"value of x=9"

NOTE:
#define sqr(x) (x*x) and
#define sqr(x) x*x
are two very different things
what Divakar and all are saying is referring to the 2nd
one, where as in this case the 1st one is given


Coming to the actual question
The value of x will remain 2, since its value is not being
changed anywhere in the program, its just being passed to a
macro, but NOT modified there either.
Try adding a line at the end of the program
printf("x=%d",x);

Is This Answer Correct ?    1 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Why array is used in c?

553


What do you mean by invalid pointer arithmetic?

637


How pointer is different from array?

584


Is it better to bitshift a value than to multiply by 2?

661


Explain union.

638






What do you understand by normalization of pointers?

627


What is the best style for code layout in c?

633


Explain bit masking in c?

639


Explain what is meant by high-order and low-order bytes?

635


Do you know the purpose of 'register' keyword?

642


Explain the Difference between the New and Malloc keyword.

688


A SIMPLE PROGRAM OF GRAPHICS AND THEIR OUTPUT I WANT SEE WAHAT OUTOUT OF GRAPHICS PROGRAM

1699


Are the variables argc and argv are local to main?

790


What are the different file extensions involved when programming in C?

760


What are the features of c languages?

632