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 5 of 5.
Mekalacheruvu purushotham said:
1 decade ago
It is a function which returns integer pointer.
Kingalbert4m said:
1 decade ago
Static member function cann't access the non static members.
Xstream said:
1 decade ago
Static members are cannot be used as arguments in a function its a general rule.
Sumit said:
1 decade ago
Static member is initialized to 0 so can't be passed as arguments.
Sucharita said:
1 decade ago
We can use static data member but for that the function should be static itself. (C++ concept).
Dhananjai said:
1 decade ago
The default storage class of a formal arguments is Register. If the CPU registers are busy then it is stored in Stack section.
Sai said:
1 decade ago
What is storage class ? can any one explain ?
Shyamala krishnan said:
1 decade ago
Storage classes is important part of c language. WHENEVER we define any function in c program then we can call that in every defined class.
Vishwas said:
1 decade ago
Static variables are declared in a function so that other functions which access it from its local function cannot change the value. Only the local function can change its value. That's why its not used in function arguments.
M@c said:
1 decade ago
#include<stdio.h>
int static a=1;
int main()
{
static int a=10;
a++;
call();
return 0;
}
call()
{
printf("Weclome to IndiaBIX.com..! %d",a);
}
o/p :
Weclome to IndiaBIX.com..! 1
Please Tell me why ?
int static a=1;
int main()
{
static int a=10;
a++;
call();
return 0;
}
call()
{
printf("Weclome to IndiaBIX.com..! %d",a);
}
o/p :
Weclome to IndiaBIX.com..! 1
Please Tell me why ?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers