C Programming - Declarations and Initializations - Discussion


What are the types of linkages?

[A]. Internal and External
[B]. External, Internal and None
[C]. External and None
[D]. Internal

Answer: Option B


External Linkage-> means global, non-static variables and functions.
Internal Linkage-> means static variables and functions with file scope.
None Linkage-> means Local variables.

Ujwala said: (Jul 19, 2010)  
Details of internal & none linkage ?

Suresh said: (Aug 16, 2010)  
What is static variable?

Ago Balan said: (Sep 14, 2010)  
int a; --> Here a is a variable of integer. We can increment the value of a using for loop.

static int a; --> Whenever 'a' is called at any line in a program 'a' value is assigned automatically that value is previous value of a we used sometime earlier in program. Actually static is storage class.

Shan said: (Sep 16, 2010)  
I wanna a briefly explain about the linkages.

Kailash said: (Oct 24, 2010)  
'static' is fixed with respect to time. But dynamic can change with respect to time.

Komal said: (Oct 29, 2010)  
I wanna a briefly explain about the linkages.

Kaamani said: (Nov 24, 2010)  
I want example program for three linkages.

Vidvesh said: (Dec 7, 2010)  
Tell me more about static variables???

Sathish Narasimman said: (Jan 7, 2011)  
static example..
int main()
printf(" %d",root());
printf(" %d",root());
int root()


static int i;
return i;

it will print the updated value every time example: o/p=1 2 3 4...

where as if we use int i in the place of static int i, in the root function.. always print 1 1 1 1

Swathy said: (Jan 20, 2011)  
@shan and @komal
external - throughout the program
internal - a single file
none - local to a single function

Arkadeep said: (Jan 31, 2011)  
@satish-thanks a lot...but why the term linkage is used for this storage classes?

Swetha said: (Feb 19, 2011)  
Where do we use this linkages.

Silpi Roy said: (Feb 25, 2011)  
What are linkages?

Prasanth Reddy.d said: (Feb 27, 2011)  
Can static variables be declared before main() ?

Prathyusha said: (Mar 5, 2011)  
//SATHISH explanation was correct!..
int main()
printf(" %d",root());
printf(" %d",root());

int root()
static int i;
return i;


Rajesh said: (Mar 10, 2011)  
We declare already a static varible, in derived class we declare one more same static variable as declared first with different value, and call the previous variable,.......then.....Is the out put of program is first variable's value or secon variale's value...

Ram Krishna said: (Apr 20, 2011)  
I will thank full to Satish Narasimman and Prathyusa, who cleared my doubt.

Siri said: (May 24, 2011)  
Good explanation pratyusha, thanq so much.

Saikiran said: (Jul 18, 2011)  
What Prathyusha said is correct. That can be easily understood using this program.

int main()
return 0;

int funi()
int i;
return i;

int funj()
static int j;
return j;


Gaurav said: (Jul 27, 2011)  
x= 5;
z = ++x + ++x ;

why does this display 14 , instead of 13 ?

DixN said: (Jul 27, 2011)  
The reason is
++x means x=6
then ++x means x=7
then only it will start to add
but at the end x=7
ie z=14 is the answer

Sumanth said: (Jul 30, 2011)  
Thanx Dixin

Purnima said: (Sep 8, 2011)  
Can you give me the brief explanation about linkages and what are the storage classes?

Sameer said: (Sep 9, 2011)  
What is the meaning of functions of filescope?

Anitha said: (Sep 27, 2011)  
How can we print a string without using printf() and any other functions like puts() & get() ?

Nidhi Gupta said: (Nov 5, 2011)  
What is static and non-static variables?

Manisha said: (Nov 12, 2011)  
What are linkage?

Nagaraj said: (Dec 25, 2011)  
fmod(3.14,2.1) is giving o/p: 0.000000 why?

Anjesh Kumar Maurya said: (Jan 3, 2012)  
Tell me about linkage?

Shwetha said: (Feb 10, 2012)  

How at end it became 7?

I didn't understand. Can you explain again please.

Apple said: (Mar 15, 2012)  

inc/dec operator has high precedence than arithmatic operators in operator precedence.so,when x=5,
++x => x=6
++x => x=7(as x is a variable that can store only a single value)
now,arithmatic operation is performed on it,ie,

Keerthi said: (Apr 24, 2012)  
Apple,U said right. but easiest way for shwetha
For 1st ++x,the value of x is first increased about one and then assign ,that means the value of x changes from 5 to 6.
Its clear in the same way the 2 nd ++x, x changes from 6 to 7
So, final value of x is 7
That means z=x+x
For 1st and 2nd x's the value is same that is 7

Raju said: (May 30, 2012)  
What's is answer for this question:z=(++x)+(x++), if x=2?

Shibu said: (Jun 9, 2012)  
@raju.... begin from the right most(x++).
x++ -> value remains 2,
now ++x -> 2 incremented to 3. now x contains the final value 3
hence z=3+3

Santosh said: (Jun 10, 2012)  
I think you have defined means %d so floating part its not showing 0. 00000, print it using %f you will get right answer.

Vidya said: (Oct 6, 2012)  
main() {
char str1[]="Hello";
char str2[]="Hello";
if ( str1==str2 )
please explain the answer

Vittu Agrawal said: (Oct 18, 2012)  
What is static and non static variables and functions ?

OP Meena said: (Oct 20, 2012)  

String variabls can not directly compare by using == operator,

string variable compare by using the strcmp() function in c and c++,
if(strcmp(str1,str2)==0)) printf("String are eqals");

In Java we compare the string by using the equals() method.

Syeda said: (Oct 23, 2012)  
For increment operators why we are begining from right most?

Its left priority right?

Laxman said: (Nov 23, 2012)  
What are linkage? Tell briefly.

Amru said: (Dec 23, 2012)  
What is the exact meaning of linkage? what exact it does. ?

Rakhi said: (Mar 5, 2013)  
What are linkage?

Praveen said: (Mar 13, 2013)  

Begin from the right most(x++).

x++ -> value remains 2,

Now ++x -> 2 incremented to 3. now x contains the final value 3 but it can't assign post increment.

Hence z = 3+2 = 5.

Sonali said: (Jun 11, 2013)  
I'm still confuse in that z value, will it be 5 or 6? and how?

@Shibu and @ Praveen.

Alok said: (Jun 20, 2013)  
@Sonali see this one.


For 1st ++x, the value of x is first increased about one and then assign, that means the value of x changes from 5 to 6.

Its clear in the same way the 2 nd ++x, x changes from 6 to 7.

So, final value of x is 7.
That means z = x+x.

For 1st and 2nd x's the value is same that is 7.

Therefore Z = 7+7.

Jhansi said: (Jul 20, 2013)  
Give details of linkages & when they are used?

Gaurav said: (Aug 27, 2013)  

Why x++ value remains 2?

Why it is not incremented by 1?

Lavanya said: (Sep 5, 2013)  
Give details of linkages & when they are used?

Aliya said: (Sep 12, 2013)  

Why the evaluation is done from the right most i.e; x++.

++x=3; the value of x=3.

x++=3; we do not increment here since its a post inc.

++x + x++ = 6?

Why aren't we considering pre inc first?

Vams said: (Sep 29, 2013)  

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.

Moumita said: (Oct 24, 2013)  
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: (Jan 20, 2014)  
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: (Jan 24, 2014)  

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: (Jan 30, 2014)  
What is linkages? how it affects the c program in terms of memory or storage class?

Sandeep said: (Feb 1, 2014)  
When x=2,
if z=x++ + ++x.
Then z=?

Sravani said: (Feb 14, 2014)  
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: (Feb 28, 2014)  
what about the following:

int i=5;
printf("%d",(++i + ++i);
it is printing 13.

While as:

int i=5,z;
z=(++i + ++i);
prints 14.

Can anyone explain why?

Lipsha said: (May 22, 2014)  
What are linkages?

RaviTeja.BSN said: (Jun 20, 2014)  
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 */


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

fp = fopen(__FILE__,"r");

c= getc(fp);
while(c != EOF);


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: (Jun 27, 2014)  
What is difference between all three ?

Shreeketh said: (Jul 21, 2014)  
What is the difference between non static variable and local variable?

Shiny said: (Aug 25, 2014)  
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.

Arvind Kumar said: (Aug 28, 2014)  
Static variable are the variable which allocate the memory as well as program start and they create only one copy for more then object.

Jatin said: (Dec 7, 2014)  
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.

Harsh said: (Jan 4, 2015)  
Can anyone explain the answer of this: z = (x++ + ++x)x = 2. And z = (++x + x++)x = 2.

Gowthami said: (Jan 10, 2015)  
What is meant by external linkage?

Priya said: (Feb 8, 2015)  
You must initialize the i with a value because it will take a garbage value by default.

Karthick said: (Apr 17, 2015)  
Why we use return in program?

Tiger said: (Jun 13, 2015)  
@Karthick we use the return in the program because the return any value for example.

int main()
int i=5;
return i;

Output of the above program is 5 because it will be return the value of the i.

Kavitha said: (Jul 12, 2015)  
int main()
int x=3;
int z;
z=++x + x++;

It gives the output 9,how?

Kasthuri said: (Aug 6, 2015)  

It will give only 8 as the output.

Manoj said: (Aug 7, 2015)  

It will give the output 8 only!

Saiba Murmu said: (Aug 19, 2015)  
It gives result according to the compiler.

GCC compiler gives Result: 9.

TCC compiler gives Result: 8.


In GCC compiler, variables are stored in stack memory area. First value 4 is stored after incrementing by the pre-increment operator then second value 5 is stored after increment. So the Result is 9.

But in case of TCC compiler first value 4 is stored in stack then before increment the second value of x=4 is stored. So the Result is 8.

Sarathi said: (Dec 4, 2015)  
Difference between GCC and TCC compiler?

Ashwini said: (Mar 8, 2016)  
What is the difference between that all three linkages?

Ashwini said: (Mar 8, 2016)  
@Saiba Murmu.

GCC compiler also giving the result : 8.
Check it once.

BALAMURUGAN said: (Mar 29, 2016)  
How you can classify those linkages respectively. Please tell me.

Anil said: (Jun 17, 2016)  
#include <stdio.h>
int main()
int i = 2;
int j = ++i + i;
printf("%d\n", j);

Output = 6.

How is it possible? Please give me an explanation.

Rashmi said: (Jun 26, 2016)  
What is meant by filescope?

Geetha said: (Jul 4, 2016)  
#include <stdio.h>
int main()
int i = 2;
int j = ++i + i;
printf("%d\n", j);

Output = 6.

Sruthi said: (Aug 10, 2016)  
What is a linkage?

Nufiqa said: (Nov 15, 2016)  
Give me the clear difference between static, non-static &local variables.

Arpita said: (Nov 22, 2016)  
What is linkages? Describe in detail.

Nanthakumar said: (Jan 27, 2017)  

#include <stdio.h>
int main()
int i = 2;
int j = ++i + i;
printf("%d\n", j);
First pre inc I=3.

Then latest value of i is 3 only no post inc can accessed in (++I)+(i)
So, 3+3 is equal to 6.

Jyothsna said: (Feb 4, 2017)  
Please give information about incremental and decremental values.

Keerthana said: (Mar 17, 2017)  
Pre increment - increment the value and then use it.

Post increment - use the value and then increment.

Lavanya said: (Sep 29, 2017)  
Can anyone tell me the difference between static and non-static variables? and also about linkages.

Sagar Prakash Pakhale said: (Mar 6, 2018)  
Pre-increment - increment the value and then use it.

Post-increment - use the value and then increment.

Prabhat said: (Mar 21, 2018)  
Pre-increment and post-increment behaviour depends on the compiler's implementation of it.

Each compiler can give you the different result for the same operation with respect to pre and post increment and decrement. As there is no standard behaviour defined by ANSI C standard.

We shouldn't use these two operators in an expression.

Vineethreddy said: (Jun 28, 2018)  
Pre increment - increment the value and then use it.

Post increment - use the value and then increment.

Neha said: (Jul 30, 2018)  
What is linkages?

Sreenu said: (Aug 15, 2018)  
What is meant by linkages?

Sudhanshu Kumar said: (Sep 13, 2018)  
Please tell definition of linkages.

Nali Srikanth said: (Jul 14, 2019)  
Static variable is a fixed.
Non static variable can be changed.
None linkage means local variable.

Manoj Mehra said: (Jan 2, 2021)  
In programming languages, particularly the compiled ones like C, C++, and D, linkage describes how names can or can not refer to the same entity throughout the whole program or one single translation unit. The static keyword is used in C to restrict the visibility of a function or variable to its translation unit.

Post your comments here:

Name *:

Email   : (optional)

» Your comments will be displayed only after manual approval.