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 2 of 10.

Jatin said:   1 decade ago
Its too late and ignore if not but it shouldn't be like this:

If x = 2.

z = x++ + ++x // here because x = 2, value 2 is assign to x (value 2 stored to perform overall function) n stored after that it'll increment by 1.

=> z = (2) ++.

That will 3. Till z = x++ value of x is 3.
After that z = 3 + ++x //till here x = 3.

So further by pre-increment 3 will incremented by 1 value will be 4. So z = 2 + 4 = 6.

Arvind kumar said:   1 decade ago
Static variable are the variable which allocate the memory as well as program start and they create only one copy for more then object.

Shiny said:   1 decade ago
Why external linkage means global, non static, functions?
Why internal linkage means static variables, functions with filescope?
Why none linkage means local variables?

Please give clear information about those three.

Shreeketh said:   1 decade ago
What is the difference between non static variable and local variable?

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

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?

Lipsha said:   1 decade ago
What are linkages?

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?

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;

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


Post your comments here:

Your comments will be displayed after verification.