Starting from:

$30

CSE114-Assignment 1 Solved

In this assignment you will implement functions and if else if clauses.

●     Function 1 :

○     Name of the function: printLine

○    Return type of the function: void ○    It takes two integer parameters a and b.

○    a presents the number of lines to print. For example if a 2 you must print 2 lines (a can be 2, 3, 4 and 5. Don’t use loops)

○    Print a times lines where each line starts a and finishes with b. ○    Between a and b, there will be three space characters. ○  For example if a and b are 2 and 3, the output will be

2   3

2   3

                        ○    For example if a and b are 4 and 2, the output will be

4    2

4   2

4   2

4   2

●     Function 2:

○     Name of the function: printTriangle

○    Return type of the function: void ○    It takes one integer parameter x.

                        ○    Print a triangle by using x like below.

                        ○    If x is odd number, for example 5 output will be

5

5    5

5 5 5

                        ○    If x is even number, for example 6 output will be

6    6 6

6 6

6

●     In the main function:

○     Ask 2 values from the user to use in function 1 

                        ○     Ask 1 more value from the user to use in function 2 

○    Call functions in the correct order to produce outputs like the examples in the next page.  You may need to call the functions more than once to produce the desired output. (20 pts)

 
 

More products