The ones who are crazy enough to think they can change the world are the ones who do.- Steve Jobs
#include <stdio.h>
int main()
{
int m = 5;
void display(){
int m = 10; //Local variable declaration
printf("Value of M inside a function is %d",m);
}
display();
printf("\nValue of M outside a function is %d",m);
return 0;
}
m is a variable used locally and globally.
If there is no declaration of variable in a subfunction. Then the value of a variable will be fetched from global declaration. Let us check the same program that we used early.
#include <stdio.h>
int main()
{
int m = 5;
void display(){
//No Local variable declaration
printf("Value of M inside a function is %d",m);
}
display();
printf("\nValue of M outside a function is %d",m);
return 0;
}
m is a variable used locally, but fetches a values globally.
We may make mistakes(spelling, program bug, typing mistake and etc.), So we have this container to collect mistakes. We highly respect your findings.
© Copyright 2019