Difference between revisions of "CPP/Debugging/Assert"

From ProgrammingExamples
< CPP
Jump to: navigation, search
(Assert.cpp)
(Undo revision 699 by 188.143.232.65 (Talk))
 
(One intermediate revision by one other user not shown)
(No difference)

Latest revision as of 09:23, 11 February 2011

Assert.cpp

#include <iostream>
#include <cassert>
#include <string>
#include <cmath>
 
using namespace std;
 
float Sqrt(float n){
 assert(n >= 0);
 return sqrt(n);
}
int main(){
 
  Sqrt(16); //pass
  Sqrt(-16); //fail
 
  return 0;
}