Data flow example

Example 1

Consider the following source code extract:

<source lang="c"> main() { int x ; if (x==42) {. . .} } </source>

A common mistake is to reference the value of a variable x without first assigning a value to it.

References

  • <bib>vincenzi-maldonado:slides:2007</bib>


Example 2

Consider the following source code extract:

<source lang="c">

  1. include <stdio.h>

main() { int x; printf("%d", x); } </source>

Naive developers unconsciously assume that the language compiler or run-time system will set all variables to zero. What is the output of the program?


References

  • <bib>vincenzi-maldonado:slides:2007</bib>