IN C STATIC VARIABLE CAN BE INITIALIZED USING ONLY CONSTANT LITERALS.........
FOR EXAMPLE :
static int i=20;
IF WE DO NOT INITIALIZE ANY VALUE THEN......
FOR EXAMPLE :
static int i;
then by default value of i will be ZERO.......
MEANS i will be 0 ......
FOR EXAMPLE :
BELLOW PROGRAM WILL GIVE COMPILE TIME ERROR...
#include<stdio.h>
int a( )
{
return 6;
}
main( )
{
static int i=a( ); /* Compile Time Error*/
printf("%d",i);
return 0;
}
Explanation: All objects with static storage duration must be initialized before execution of main() starts......
FOR EXAMPLE :
static int i=20;
IF WE DO NOT INITIALIZE ANY VALUE THEN......
FOR EXAMPLE :
static int i;
then by default value of i will be ZERO.......
MEANS i will be 0 ......
Note: All objects with static storage duration must be initialized before execution of main() starts......
FOR EXAMPLE :
BELLOW PROGRAM WILL GIVE COMPILE TIME ERROR...
#include<stdio.h>
int a( )
{
return 6;
}
main( )
{
static int i=a( ); /* Compile Time Error*/
printf("%d",i);
return 0;
}
Explanation: All objects with static storage duration must be initialized before execution of main() starts......
No comments:
Post a Comment