Demonstrating assertions with assert function - C Language Basics

C examples for Language Basics:assert

Description

Demonstrating assertions with assert function

Demo Code

#include <stdio.h>
#include <assert.h>

int main(void)
{
  int y = 5;/*from w  w w .j  av  a 2  s .c  om*/
  for(int x = 0 ; x < 20 ; ++x)
  {
    printf("x = %d   y = %d\n", x, y);
    assert(x < y);
  }
  return 0;
}

Result


Related Tutorials