From: Nava2
We aren't here for your homework, man.
I know but if you read the post i didn't understand the questions
From: anonymity
+ 1
[COLOR="White"]int main (void) { // main program directive
int initial_num = 0, final_num = 0, current_num = 0, print_num = 0; //numbers to use
get_initial_num // from end user - in this case it is 1
get_final_num // from end user - in this case it is 4
current_num = initial_num; // sets the current number to the initial number
do { // begin the first loop while current number is <= final number
print_num = initial_num; //initializes the first number to be printed as "initial"
while (print_num <= current_num) { // starts the printing loop
print (print_num ); //prints from initial to current
print_num = print_num + 1; //adds one to the next number to be printed
} // end nested loop
print(enter[newline]); // enter/return down one line
current_num = current_num + 1; // adds one to the current end number
} while (current_num <= final num); //end main loop/conditional
return 0;
}[/COLOR]
BEGIN mainprogram
SET initialNum = 1
SET finalNum = 4
SET currentNum = 0
SET printNum = 0
currentNum = initialNum
WHILE currentNum <= finalNum
printNum = initialNum
WHILE printNum <= currentNum
PRINT printNum
printNum = printNum + 1
ENDWHILE
print(NEWLINE)
currentNum = currentNum + 1
ENDWHILE
END mainprogram
Thats what i did :)
I don't really get this question i started it off with
Write and a procedure NextLight which accepts that previous value of type StopLightType as declared below:
StopLightType = [Green, Amber, Red]
And returns the value that would come next on a "real-life" light. For instance, after amber comes red; then after red comes green, etc.
BEGIN NextLight(Value)
SET S = 0
IF Value = StopLightType[2] THEN
PRINT "Green"
EXIT
ENDIF
FOR i = 0 to 2
IF Value = StopLightType[i] THEN
S = i
IF StopLightType[S] = StopLightType[S - 1] THEN
PRINT StopLightType[S + 1]
EXIT FOR
ENDIF
ENDIF
END NextLight