Integer Variables

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Jvzj017
    New Member
    • Oct 2006
    • 10

    Integer Variables

    Given the integer variables x , y , and z , write a fragment of code that assigns the smallest of x , y , and z to another integer variable min .

    Assume that all the variables have already been declared and that x , y , and z have been assigned values).
  • dariophoenix
    New Member
    • Oct 2006
    • 34

    #2
    Originally posted by Jvzj017
    Given the integer variables x , y , and z , write a fragment of code that assigns the smallest of x , y , and z to another integer variable min .

    Assume that all the variables have already been declared and that x , y , and z have been assigned values).
    if ( (x<=y) && (x<=z) ) min = z;
    else
    if (y <= z) min = y;
    else min = z

    Comment

    • Jvzj017
      New Member
      • Oct 2006
      • 10

      #3
      Thanks ALOT!!

      Comment

      • dynamicleo
        New Member
        • Oct 2006
        • 14

        #4
        min = x;

        if (min > y) min = y;

        if (min > z) min = z;

        Comment

        Working...