What is Blocks and Scope in c ?

C Programming Language >   Variable in C Language >   Variable types and Scope in C  

Short Question

1176


Answer:

C is a block-structured language. Blocks are delimited by { and}. Every block can have its own local variables. Blocks can be defined wherever a C statement could be used. No semi-colon is required after the closing brace of a block.

Code:


#include<stdio.h>
#define semicolon ;
void main() 
{
 
  int a = 5;
  printf("\n%d", a);
  
  {
  int  a = 2;
  printf("\n%d", a);
  }
 
	
}

Output:

5
2Press any key to continue . . .

Reference to a variable will be to the variable of that name in the nearest enclosing block.


This Particular section is dedicated to Question & Answer only. If you want learn more about C Programming Language. Then you can visit below links to get more depth on this subject.




Join Our telegram group to ask Questions

Click below button to join our groups.