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 3 of 5.
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 ?
Karthik said:
1 decade ago
Can any one explain that, what happens when the parameters are non-static?
Ashi said:
1 decade ago
Can anyone tell me what is the reason why we can not pass static variables in a function?
Anonymous said:
1 decade ago
Static variables can not be declared inside method. These are always declared inside the main method.
Damodharam said:
1 decade ago
@ M@C:
The static variable is initialized to "1" as global variable and in local block variable is initialized to "10". Since both are same variables when the local block finishes and comes to the function call it will take value of global variable and it is printed as output.
The static variable is initialized to "1" as global variable and in local block variable is initialized to "10". Since both are same variables when the local block finishes and comes to the function call it will take value of global variable and it is printed as output.
Rasu said:
1 decade ago
I am using visual c++, in that I can able to pass static variable as the arguments, it is showing only warning.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers