Assert Example (1/3) - PowerPoint PPT Presentation

1 / 3
About This Presentation
Title:

Assert Example (1/3)

Description:

... lx-(12:38pm): gcc -Wall -ansi beers.c. ecs122pc37-lx ... 1.000000 bottles of beer on the wall. 1.000000 bottles of beer. Take a ... beer on the wall ... – PowerPoint PPT presentation

Number of Views:13
Avg rating:3.0/5.0
Slides: 4
Provided by: daniel523
Category:
Tags: assert | example | wall

less

Transcript and Presenter's Notes

Title: Assert Example (1/3)


1
Assert Example (1/3)
  • /
  • Program beers.c
  • How many beers are left after 5 rounds?
  • /
  • include ltstdio.hgt
  • include ltassert.hgt
  • int main()
  • / Declare variable /
  • float beers
  • for (beers 1.0 beers ! 0.0 beers - 0.2)
  • assert ( beers gt 0.0 )
  • printf("f s\nf s\n", beers, "bottles
    of beer on the wall",
  • beers, "bottles of beer")
  • printf("Take a fifth down, pass it
    around\n")

2
Assert Example (2/3)
  • ecs122pc37-lx-(1238pm) gcc -Wall -ansi beers.c
  • ecs122pc37-lx-(1238pm) a.out
  • 1.000000 bottles of beer on the wall
  • 1.000000 bottles of beer
  • Take a fifth down, pass it around
  • 8.000000e-01 bottles of beer on the wall
  • 0.800000 bottles of beer on the wall
  • 0.800000 bottles of beer
  • Take a fifth down, pass it around
  • 6.000000e-01 bottles of beer on the wall
  • 0.600000 bottles of beer on the wall
  • 0.600000 bottles of beer
  • Take a fifth down, pass it around
  • 4.000000e-01 bottles of beer on the wall
  • 0.400000 bottles of beer on the wall
  • 0.400000 bottles of beer

3
Assert Example (3/3)
  • 0.200000 bottles of beer on the wall
  • 0.200000 bottles of beer
  • Take a fifth down, pass it around
  • 3.278255e-08 bottles of beer on the wall
  • 0.000000 bottles of beer on the wall
  • 0.000000 bottles of beer
  • Take a fifth down, pass it around
  • -2.000000e-01 bottles of beer on the wall
  • a.out beers.c22 main Assertion beers gt 0.0'
    failed.
  • Abort
  • ecs122pc37-lx-(1238pm)
Write a Comment
User Comments (0)
About PowerShow.com