Back to notes -- Keyboard shortcut: 'u'        next -- Keyboard shortcut: 'n'  Slide program -- Keyboard shortcut: 't'    Demonstrations of definite assignment.Lecture 2 - slide 14 : 43
Program 1
using System;

class DefiniteAssignmentDemo{

  public static void Main(){
    int a, b;                                       
    bool c;                                         

    if (ReadFromConsole("Some Number") < 10){       
       a = 1; b = 2;                                
    } else {
       a = 2;
    }

    Console.WriteLine(a);  
    Console.WriteLine(b);  // Use of unassigned local variable 'b'

    while (a < b){
      c = (a > b);
      a = Math.Max(a, b);
    }

    
    Console.WriteLine(c);  // Use of unassigned local variable 'c'

  }

  public static int ReadFromConsole(string prompt){     
    Console.WriteLine(prompt);                          
    return int.Parse(Console.ReadLine());               
  }
}
 
 
 
 
 
Declaration of three variabels 
a, b, and c.
 
ReadFromConsole is programmed
at the bottom of this program.
 
 
 
 
Use of a and b.
 
 
 
 
 
 
 
Use of c.
 
 
 
 
Prompt user
and read and return an integer.