#include<stdio.h>
  int i=5;
  main()
  {
 int i=6;
  {

    int i=7;
    printf("%d",i);

  }
   printf("%d",i);
  }

Why does the above code doesnot give a variable redifinition error..Although the variable i is defined outside of block also??

You are allowed to redefine a variable inside a deeper scope. This is commonly called "shadowing" and it's generally regarded as a bad idea.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.