C Programming - Declarations and Initializations - Discussion

Discussion Forum : Declarations and Initializations - General Questions (Q.No. 2)
2.
What are the types of linkages?
Internal and External
External, Internal and None
External and None
Internal
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.
Discussion:
95 comments Page 6 of 10.

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?

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.

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.

Manukumar said:   1 decade ago
What is linkages? how it affects the c program in terms of memory or storage class?

Sandeep said:   1 decade ago
When x=2,
if z=x++ + ++x.
Then z=?

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;

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?

Lipsha said:   1 decade ago
What are linkages?

RaviTeja.BSN said:   1 decade ago
In one interview TR asked me to write a program that prints its source code, after that I got that program in c programing app in play store but i can't understand the program.

Print Source Code - /* Write a program that prints its own code as the output */

#include<stdio.h>

int main() {
FILE *fp;
char c;

fp = fopen(__FILE__,"r");

do{
c= getc(fp);
putchar(c);
}
while(c != EOF);

fclose(fp);

getch();
return 0;
}

And in the app he showed same program as output including the #include everything how is it possible anyone please explain?

Ashish dharjiya said:   1 decade ago
What is difference between all three ?


Post your comments here:

Your comments will be displayed after verification.