What is Blocks and Scope in c ?
Short Answer
Views 1129
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 #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.
Related Articles:
This section is dedicated exclusively to Questions & Answers. For an in-depth exploration of C Programming Language, click the links and dive deeper into this subject.
Join Our telegram group to ask Questions
Click below button to join our groups.