View Full Version : Software H/w
Simtoon
10-21-2010, 11:18 AM
I don't get these questions i need to write these questions in pseudocode
Q1)
Write an algorithm that sets a Boolean variable named Danger to True and stops reading in the data if Pressure ( the double variable being read in ) exceeds 510.0. Use Dangers as the flag to control the loop.
The Claw
10-21-2010, 11:32 AM
danger == true
while danger = true
if pressure > 510 then
danger == false
abc
Nava2
10-21-2010, 04:26 PM
danger = false
while not danger:
danger = pressure >= 510.0
sleep(16)
hai.
Simtoon
10-21-2010, 08:03 PM
Write a program using nested loop(s) to produce the following output
1
1 2
1 2 3
1 2 3 4
Nava2
10-21-2010, 08:47 PM
We aren't here for your homework, man.
anonymity
10-21-2010, 09:20 PM
+ 1
We aren't here for your homework, man.
But if you would like the logic for that next question I have the problem written out below... Cheating won't help you in the long run. I wrote it in pseudo C. The logic is the same. You should be able to get it if you need the help. It took me just a couple minutes to write out. Just give it a few minutes and if you need the help feel free to show what you have and how you are stuck. Give it a few minutes more and try by imagining or actually drawing out what you need to accomplish and the steps you would need to get there. Give it a try. It's not to bad. :)
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;
}
Simtoon
11-06-2010, 12:27 AM
We aren't here for your homework, man.
I know but if you read the post i didn't understand the questions
+ 1
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;
}
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
Powered by vBulletin® Version 4.2.1 Copyright © 2024 vBulletin Solutions, Inc. All rights reserved.