Starting from:

$25

CSE1321-Lab 7 Loop Structures Solved

Exercise #1: Design and implement a program (name it Shape) that uses next loops to printout the shape shown below. Document your code. 

 

         *  

        ***  

       *****  

      *******  

     *********  

    ***********  

   *************  

  ***************  

 

 

Exercise #2: Design and implement a program (name it SumEven) that uses while loops to read an integer number between 20 and 60, then the program prints out the entered value followed by the sum of all even integer values between 2 and the entered number (including the entered value if even). Use a while loop to validate the user input before determining and printing the sum. Document your code and properly label the input prompt and the outputs as shown below. 

 

 Sample run 1: 

 

Entered value: 20  

Sum of even numbers between 2 and 20 is 110  

 

 Sample run 2: 

 

Entered value: 25  

Sum of even numbers between 2 and 25 is 156 

 

 Sample run 3: 

 

Entered value: 60  

Sum of even numbers between 2 and 60 is 930 

 

 

Exercise #3: Write a nested loop that asks the user for symbol (store in a char) and a number.  The loop should output a rectangle (or square) of the character that is of the height and width of the number.  E.g., if I input 4 and *, I would get:

 

**** 

**** 

**** 

**** 

More products