display a menu
1 for program on strings
2 for program on pythagorean triples
enter your choice:
if the user enters 1 your program should execute the strings program
if the user enters 2 your program should do the pythagorean triples.
program accepts two strings from the user and comapres them
If the strings match, your program prints "Match"
else if there is a common prefix (beginning characters), your program
prints those characters
else if there is a common suffix (ending characters), your program prints
those characters
else if there are any matching characters, your program prints those matching
characters.
Please follow the sample run of the program carefully, Your program should produce
the SAME output for the input used in this sample run.
Sample run:
enter string 1 <ctrl d to quit> stagger
enter string 2 <ctrl d to quit> dagger
the two strings have mathinc characters: ager
enter string 1 <ctrl d to quit> worcester
enter string 2 <ctrl d to quit> leicester
the two strings have a matching suffix: cester
enter string 1 <ctrl d to quit> worcester
enter string 2 <ctrl d to quit> worcmastet
the two strings have a common prefix: worc
enter string 1 <ctrl d to quit> mystring
enter string 2 <ctrl d to quit> yourballoon
the two strings have maching character:
enter string 1 <ctrl d to quit> ^d
normal termination!
Note: the ctrl d exit option is optional. You will not lose any points if you
did not incorporate that.
Part II
program accepts a non-negative integer from the user and prints all
possible pythagorean triples, where each number in the triple is less than
or equal to the non-negative number given by the user.
here's the sample run:
enter bound: <ctrl d to quit>
(5,4,3)
total no of triples upto 5 is: 1
enter bound: <ctrl d to quit>
(5,4,3)
(10,8,6)
total no of triples upto 12 is: 2
enter bound: <ctrl d to quit>
(5,4,3)
(10,8,6)
(13,12,5)
(15,12,9)
(17,15,8)
(20,16,12)
(25,20,15)
(25,24,7)
(26,24,10)
(29,21,20)
(30,24,18)
(34,30,16)
(35,28,21)
(37,35,12)
(39,36,15)
(40,32,24)
(41,40,9)
total no of triples upto 44 is: 17
enter bound: <ctrl d to quit>
(5,4,3)
(10,8,6)
(13,12,5)
(15,12,9)
(17,15,8)
(20,16,12)
(25,20,15)
(25,24,7)
(26,24,10)
(29,21,20)
(30,24,18)
(34,30,16)
(35,28,21)
(37,35,12)
(39,36,15)
(40,32,24)
(41,40,9)
(45,36,27)
(50,40,30)
(50,48,14)
(51,45,24)
(52,48,20)
(53,45,28)
(55,44,33)
total no of triples upto 56 is: 24
enter bound: <ctrl d to quit>
normal termination!