C Programming - Pointers - Discussion
Discussion Forum : Pointers - Find Output of Program (Q.No. 8)
8.
What will be the output of the program ?
#include<stdio.h>
int *check(static int, static int);
int main()
{
int *c;
c = check(10, 20);
printf("%d\n", c);
return 0;
}
int *check(static int i, static int j)
{
int *p, *q;
p = &i;
q = &j;
if(i >= 45)
return (p);
else
return (q);
}
Discussion:
50 comments Page 1 of 5.
Sachin said:
1 decade ago
Can any one explain this one please?
Shrinivas said:
1 decade ago
Please, Can any one explain what kind of function is this?
int *check(static int i, static int j)
int *check(static int i, static int j)
Nikhil said:
1 decade ago
Parameters are never static.. its not allowed
Sindhu said:
1 decade ago
Static means those variables are initialized as 0,,so static can never be passed as function arguments...
Tim said:
1 decade ago
This is another C# trick, not ANSI C. No one should use C# unless they want to write non-portable code.
Mani said:
1 decade ago
Static member function cannot access the non static members.
Apurva Nigam said:
1 decade ago
@Mani:
Here the function is NON STATIC. so does it mean it cant access static variables???
What if both(ie parameters and function) were static??
Then the code would be correct??
Or
@Nikhil:
u mean Parameters can never be static whether its a STATIC or NON STATIC function???
Here the function is NON STATIC. so does it mean it cant access static variables???
What if both(ie parameters and function) were static??
Then the code would be correct??
Or
@Nikhil:
u mean Parameters can never be static whether its a STATIC or NON STATIC function???
Ramesh said:
1 decade ago
@apurva nigam.
Remember that, like any other local variable, a static variable cannot be referred to outside the function.
Remember that, like any other local variable, a static variable cannot be referred to outside the function.
Gopi said:
1 decade ago
Static variables will never change its value but parameters used in function should suppose to have different values.
Sarang S. Metkar said:
1 decade ago
Can anyone tell me what is d meanining of "timid" ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers