#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

Where we use clrscr in c?

892


What is the benefit of using const for declaring constants?

797


Is file a keyword in c?

678


When should the volatile modifier be used?

875


design and implement a data structure and performs the following operation with the help of file (included 1000 student marks in 5 sub. and %also) 1.how many students are fail in all 5 subjects (if >35) 2. delete all student data those are fail in all 5 subjects. 3. update the grace marks (5 no. if exam paper is 100 marks) 4. arrange the student data in ascending order basis of marks. 5.insert double of deleted students with marks in the list.

1711


Explain 'far' and 'near' pointers in c.

889


Explain the term printf() and scanf() used in c language?

807


What is variables in c?

799


What is auto keyword in c?

957


can anyone please tell about the nested interrupts?

1863


Why shouldn’t I start variable names with underscores?

828


Explain bit masking in c?

891


What is the best way to store flag values in a program?

762


Difference between Function to pointer and pointer to function

829


How can I generate floating-point random numbers?

788