Activity 2

3. Output or Prints the following pattern. Ask the user for the value of Seed ( number of rows). You can print in the next line by printing '\n' or putting the '\n' inside the double quotes. You may also print a special variable endl.

CPE102L
1Q1819
  1. Seed = 4
    
    *****
    *****
    *****
    *****
  2. start
    
    int rows
    int i=1
    
    print “Enter number of rows: ”
    input rows
    
    while (i<=rows)
    	print ”*****\n”
    	i++
    endwhile
    
    end


  3. Seed = 3
    
    ABCDE
    FGHIJ
    KLMNO
    Note: If the logic run out of letter you just go back to character 'A'
  4. start
    
    int rows
    int i=1, init=1
    char out=’A’
    
    print “Enter number of rows: ”
    input rows
    
    while (i<=rows)
    	while (init<=5)
    		print out
    		init++
    		out++
    		if (out>Z)
    			out=’A’
    		endif
    	endwhile
    	print endl
    	init=1
    	i++
    endwhile
    
    end


  5. Seed = 5
    
        *
       **
      ***
     ****
    *****
  6. start
    
    int rows
    int i=1, i2=1, i3
    
    print “Enter number of rows: ”
    input rows
    
    int temprows=rows
    i3=temprows
    while (i<=rows)
    	while (i2<temprows)
    		print “ “
    		i2++
    	endwhile
    	i2=1
    	while (i3<=rows && i3>0)
    		print “*”
    		i3++
    	endwhile
    	i3=temprows-1
    	temprows--
    	print endl
    	i++
    endwhile
    
    end


  7. Seed = 6
    
         *
        * *
       * * *
      * * * *
     * * * * *
    * * * * * *
  8. start
    
    int rows
    int i=1, i2=1
    
    print “Enter number of rows: ”
    input rows
    
    int temprows=rows
    int i3=temprows
    while (i<=rows)
    	while (i2<temprows)
    		print “ “
    		i2++
    	endwhile
    	i2=1
    	while (i3<=rows && i3>0)
    		print “* ”
    		i3++
    	endwhile
    	i3=temprows-1
    	temprows--
    	print endl
    	i++
    endwhile
    
    end


  9. Seed = 5
    
    BCDFG
    HJKLM
    NPQRS
    TVWXY
    ZBCDF
    Note: If the logic run out of letter you just go back to character 'A'
  10. start
    
    int rows
    int i=1, init=1
    char out=’A’
    
    print “Enter number of rows: ”
    input rows
    
    while (i<=rows)
    	while (init<=5)
    		if (out==’A’ || out==’E’ || out==’I’ || out==’O’ || out==’U’)
    			out++
    		endif
    		print out
    		init++
    		out++
    		if (out>Z)
    			out=’A’
    		endif
    	endwhile
    	print endl
    	init=1
    	i++
    endwhile
    
    end