C Programming - Declarations and Initializations - Discussion
Discussion Forum : Declarations and Initializations - General Questions (Q.No. 2)
2.
What are the types of linkages?
Answer: Option
Explanation:
External Linkage-> means global, non-static variables and functions.
Internal Linkage-> means static variables and functions with file scope.
None Linkage-> means Local variables.
Internal Linkage-> means static variables and functions with file scope.
None Linkage-> means Local variables.
Discussion:
95 comments Page 3 of 10.
Hilal Bhat said:
1 decade ago
what about the following:
int i=5;
printf("%d",(++i + ++i);
it is printing 13.
While as:
int i=5,z;
z=(++i + ++i);
printf("%d",z);
prints 14.
Can anyone explain why?
int i=5;
printf("%d",(++i + ++i);
it is printing 13.
While as:
int i=5,z;
z=(++i + ++i);
printf("%d",z);
prints 14.
Can anyone explain why?
Sravani said:
1 decade ago
Hey guys x++ + ++x though we are making changes to x that will be updated in register because of optimization it treats both x as same value and makes z=x+x;
x++=value is incremented after the statement completes and x=2.
After ++x= pre inc so x in inc and x value is 3 and is stored in only one place now addition happens z=x+x,z=3+3=6;
But if you use volatile in front of int x; then it will give z=5;
x++=value is incremented after the statement completes and x=2.
After ++x= pre inc so x in inc and x value is 3 and is stored in only one place now addition happens z=x+x,z=3+3=6;
But if you use volatile in front of int x; then it will give z=5;
Sandeep said:
1 decade ago
When x=2,
if z=x++ + ++x.
Then z=?
if z=x++ + ++x.
Then z=?
Manukumar said:
1 decade ago
What is linkages? how it affects the c program in terms of memory or storage class?
Bhavani said:
1 decade ago
@Moumita.
When x=5 then,
Z=++x + ++x;
Is printing 14 not 13.
I checked it guys,
x = 7 at last, Because a value of a variable(x) vl hold the latest value that's being stored in the memory(i.e) 7.
So z = 7+7 = 14.
When x=5 then,
Z=++x + ++x;
Is printing 14 not 13.
I checked it guys,
x = 7 at last, Because a value of a variable(x) vl hold the latest value that's being stored in the memory(i.e) 7.
So z = 7+7 = 14.
Mounika said:
1 decade ago
13 because here first x = 5.
Then ++x = 6(pre increment).
Now x = 6.
Then ++x = 7.
So z = ++x + ++x.
z = 6+7 => 13.
Then ++x = 6(pre increment).
Now x = 6.
Then ++x = 7.
So z = ++x + ++x.
z = 6+7 => 13.
Moumita said:
1 decade ago
Guys please check this once more.
When x =5 then,
Z=++x + ++x;
Is printing 13 not 14....
So what is the actual explanation?
When x =5 then,
Z=++x + ++x;
Is printing 13 not 14....
So what is the actual explanation?
Vams said:
1 decade ago
@Aliya.
C compiler does parsing (reading and evaluating) from left to right of each line of code. That is purely related to compiler design(cd) topic for further details refer cd of C language.
C compiler does parsing (reading and evaluating) from left to right of each line of code. That is purely related to compiler design(cd) topic for further details refer cd of C language.
Lavanya said:
1 decade ago
Give details of linkages & when they are used?
BALAMURUGAN said:
1 decade ago
How you can classify those linkages respectively. Please tell me.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers