There is a problem my professor assigned. It's not suppose to be complicated but I can't grasp the concept. I can grasp it in the english language but if I turn it into Pascal, I have no idea what to do.
Here's the problem and what I have created in pascal so far.
Write a program that reads in four words and displays them in increasing alphabetical sequence and also in decreasing alphabetical sequence. My professor also added to make the program to any number of inputs. (Great hahah)
program alpha; var word1, word2, word3, word4, Temp : string; begin Writeln ('Enter in the 1st word'); Readln (word1); Writeln ('Enter in the 2nd word'); Readln (word2); Writeln ('Enter in the 3rd word'); Readln (word3); Writeln ('Enter in the 4th word'); Readln (word4); If word1 > word2 then begin Temp := word1; word1 := word2; word2 := Temp; Writeln (word1, word2) end; If word3 > word4 then begin Temp := word3; word3 := word4; word4 := Temp; Writeln (word3, word4) end; end.
So you see, I can sort out word1 and word2 fine and word3 and word4. I don't know what statement order to put next to sort out these 4 words and then go on to sort any number of words. :confused: I was thinking of adding a case statement to ask the user in the beginning if he wants to end this program, to type in a letter or string.
My professor just got assigned to teaching this class2 days before it opened since most of us need it to graduate. He is new and doesn't have anything prepared. He goes along with the book as we do and is basically on the same level as us. I just don't know add to this. The book doesn't go into any details into this problem. Arrays are in the later chapters and I he doesnt want us to use that just what we have learned so far.
Any help would be appreciative. This is due today and I have been working on this for over a week so I am desperately trying to find a way to complete this.