*************** *************** *************** *********
program for sharing memory
*************** *************** *************** *********
#include"stdio. h"
#include"conio. h"
#include"file12 .c"
int a,b,c;
void main()
{
clrscr();
printf("\nvalue of a,b and c before extern");
printf("\nADDRE SS of a--> %x",&a);
printf("\nADDRE SS of b--> %x",&b);
printf("\nADDRE SS of c--> %x",&c);
printf("\n\nval ue of function function()--> %d",function()) ;
printf("\n\nval ue of function div()--> %d",div());
printf("\n\nval ue of function mul--> %d",mul());
printf("\n\nval ue of a,b and c after extern");
printf("\nADDRE SS of a--> %x",&a);
printf("\nADDRE SS of b--> %x",&b);
printf("\nADDRE SS of c--> %x",&c);
getch();
}
int function()
{
a=24;
b=a*a;
return(b);
}/*completed*/
*************** *************** *************** *************
"file12.c"
*************** *************** *************** *************
#include"stdio. h"
#include"conio. h"
extern int a,b,c;
int mul()
{
a=40;
b=30;
c=a+b/4;
return(c);
}
int div()
{
c=73;
b=24;
a=c/b;
return(a);
}/*completed*/
*************** *************** *************** *************** ****
output of this program
*************** *************** *************** *************** ******
ADDRESS of a,b and c before extern
ADDRESS of a--> 582
ADDRESS of b--> 584
ADDRESS of c--> 586
value of function function()--> 576
value of function MUL()--> 47
value of function DIV--> 3
ADDRESS of a,b and c after extern
ADDRESS of a--> 582
ADDRESS of b--> 584
ADDRESS of c--> 586
*************** *************** *************** *************** *
i am having MY QUESTION
*************** *************** *************** *************** *
1)In this output THE ADDRESS OF a,b,c having 582,584,586.... .....how this number comes.
2)then in that second program (file12.c) having extern int a,b,c...in one book the author told ,"this extern is used for sharing memory". so only the value of a,b,c are not changed in the output..but one time am executing this program without extern...at tat time also it shows the same value as output...i changed the extern from this program to that program and also vice versa..whatever i did the output come as it is ...what is the use of extern....
program for sharing memory
*************** *************** *************** *********
#include"stdio. h"
#include"conio. h"
#include"file12 .c"
int a,b,c;
void main()
{
clrscr();
printf("\nvalue of a,b and c before extern");
printf("\nADDRE SS of a--> %x",&a);
printf("\nADDRE SS of b--> %x",&b);
printf("\nADDRE SS of c--> %x",&c);
printf("\n\nval ue of function function()--> %d",function()) ;
printf("\n\nval ue of function div()--> %d",div());
printf("\n\nval ue of function mul--> %d",mul());
printf("\n\nval ue of a,b and c after extern");
printf("\nADDRE SS of a--> %x",&a);
printf("\nADDRE SS of b--> %x",&b);
printf("\nADDRE SS of c--> %x",&c);
getch();
}
int function()
{
a=24;
b=a*a;
return(b);
}/*completed*/
*************** *************** *************** *************
"file12.c"
*************** *************** *************** *************
#include"stdio. h"
#include"conio. h"
extern int a,b,c;
int mul()
{
a=40;
b=30;
c=a+b/4;
return(c);
}
int div()
{
c=73;
b=24;
a=c/b;
return(a);
}/*completed*/
*************** *************** *************** *************** ****
output of this program
*************** *************** *************** *************** ******
ADDRESS of a,b and c before extern
ADDRESS of a--> 582
ADDRESS of b--> 584
ADDRESS of c--> 586
value of function function()--> 576
value of function MUL()--> 47
value of function DIV--> 3
ADDRESS of a,b and c after extern
ADDRESS of a--> 582
ADDRESS of b--> 584
ADDRESS of c--> 586
*************** *************** *************** *************** *
i am having MY QUESTION
*************** *************** *************** *************** *
1)In this output THE ADDRESS OF a,b,c having 582,584,586.... .....how this number comes.
2)then in that second program (file12.c) having extern int a,b,c...in one book the author told ,"this extern is used for sharing memory". so only the value of a,b,c are not changed in the output..but one time am executing this program without extern...at tat time also it shows the same value as output...i changed the extern from this program to that program and also vice versa..whatever i did the output come as it is ...what is the use of extern....
Comment