Q:

if else statement within a function ...which is a good practice?

I have 2 piece of code that I would like to know the reason for using either one.Both works but which is a good practice in C?
Option 1
Void GoodPractice()
{
  bool flag;

  if (right)
  {
    flag=1;
  }
  else
  {
    flag=0;
  }
}

OR
Option 2
Void GoodPractice()
{
  bool flag=0;

  if (right)
  {
    flag=1;
  }
}

Let me know why as well.
Thanks.

A:

It depends on what you want to do.
In general second version  is better than the first one, because there is no code section where flag is not defined. 
Void GoodPractice()
{
   bool flag=0;
   // you can use flag  
   if (right)
   {
      flag=1;
   }
}

Void NotAsGoodPractice()
{
   bool flag;
   // you can't use flag, because it has no defined value
   if (right)
   {
      flag=1;
   }
   else
       flag=0;
}

