Hardware Reference
In-Depth Information
CASE "3"
CALL SortData
CASE "4"
CALL PrintData
CASE "5"
CALL UpdateFile
CASE "6"
EXIT DO
CASE ELSE
BEEP
PRINT "Input not valid!"
END SELECT
while its equivalent in C would be:
switch(c)
{
case '1':
newdata();
break;
case '2':
olddata();
break;
case '3':
sortdata()
break;
case '4':
printdata()
break;
case '5':
exit ()
default
beep()
printf("Input not valid!\n")
}
Loops
A loop structure (backwards branch) may be used in order to avoid the need to
repeat blocks of code several times over whenever a process is to be repeated
more than once. Various types of loops are possible (both conditional and
unconditional) and these are supported by pseudo code statements such as Do
... Loop While , Do ... Loop Until , Do While ... Loop , and Do Until
... Loop .
As an example of a simple loop, the following C++ code fragment prints the
numbers 1 to 10 separated by spaces:
for (count = 1; count <= 10; count++)
cout << cout << "";
This routine uses the C++ increment operator, count++ , however we could have
obtained the same result using:
for (count = 1; count <= 10; count = count + 1)
cout << cout << "";
Search WWH ::




Custom Search