C/C++ Programming
Tutorial 3. Decisions and Loops

1. Explain specifically why GOTO is considered harmful.

2. Assume that the collateral operator is ``,'' and that the sequential operator is ``;''. Rewrite the following program using the collateral operators whenever you can (hint: look for read/write conflicts). In other words it is required to define the operations that can be executed in parallel (,) and consequently (;).

   x = 4;
   y = 23;
   z = x + y;
   printf("%d", z);
   x = zoo(x, y, z);

3. Write a simple C program that converts Fahrenheit temperature between 0 to 300 degree into equivalent Celsius.

4. Write a weight conversion program on C. Hint: the ratio of kilo/pound = 0.45359.

5. Interpret the following command:

              for (hi = 100, lo = 0; hi >= lo; hi--, lo++) i++;

6. A function returning the length of a string is given below. Will this function shown below produce correct result? Hint: Remember that the string is represented as an array of characters terminated by a null character '\0'.

int string_length(string)
char string[];
{       int i = 0;
        do { i++;
        } while (string[i] != '\0')

        return(i);
}