Back to slide -- Keyboard shortcut: 'u'  previous -- Keyboard shortcut: 'p'                declaration-statements/decl-in-if.cc - A declaration in the condition of an if.Lecture 2 - slide 8 : 29
Program 3

double g(int a, double d){
  return a * d;
}

double f(double p){
  int i = 0;

  if (p <= 10.0) i++;             // Some statements 

  if (double result = g(i,p)){    // A declaration in a condition
    return result * result;
  }
  else{
    return 1 / result;
  }

  /* Rest of f comes here */
}

int main(){
  f(5.0);
}