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.
Anil said:
9 years ago
#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.
int main()
{
int i = 2;
int j = ++i + i;
printf("%d\n", j);
}
Output = 6.
How is it possible? Please give me an 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.
Praveen said:
1 decade ago
@Raju.
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.
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.
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?
Vidya said:
1 decade ago
main() {
char str1[]="Hello";
char str2[]="Hello";
if ( str1==str2 )
printf("True");
else
printf("False");
}
ans:false
please explain the answer
char str1[]="Hello";
char str2[]="Hello";
if ( str1==str2 )
printf("True");
else
printf("False");
}
ans:false
please explain the answer
Shibu said:
1 decade ago
@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
=6
x++ -> value remains 2,
now ++x -> 2 incremented to 3. now x contains the final value 3
hence z=3+3
=6
DixN said:
1 decade ago
The reason is
x=5
++x means x=6
then ++x means x=7
then only it will start to add
z=x+x
but at the end x=7
therefore
z=7+7
ie z=14 is the answer
x=5
++x means x=6
then ++x means x=7
then only it will start to add
z=x+x
but at the end x=7
therefore
z=7+7
ie z=14 is the answer
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.
Santosh said:
1 decade ago
@Nagaraj.
I think you have defined means %d so floating part its not showing 0. 00000, print it using %f you will get right answer.
I think you have defined means %d so floating part its not showing 0. 00000, print it using %f you will get right answer.
Swathy said:
1 decade ago
@shan and @komal
external - throughout the program
internal - a single file
none - local to a single function
external - throughout the program
internal - a single file
none - local to a single function
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers