[SOLVED] IT1010 - Lab Sheet4 -  Introduction to Programming

30.00 $

Category:

Description

5/5 - (1 vote)

Objectives:

At the end of the class the students should be able to:

 Implement simple functions in C language

 

Exercise 1: 

 

  1. Write a function drawLines() to draw the below figure.

 

  • * * * * * * * * *
  • * * * * * * * * *
  • * * * * * * * * *
  • * * * * * * * * *
  • * * * * * * * * *

 

  1. Call the drawLines() function in your main program to draw the rectangle.

 

  • Write another function called drawLinesWithRow() to pass the no of lines(rows) as a parameter.

 

 

Ex: void drawLinesWithRow(int rows)

If 3 is passed as the number of rows, the function should print,

 

  • * * * * * * * * *
  • * * * * * * * * *
  • * * * * * * * * *

 

  1. Call the function created in section c) in your main program and draw two rectangles with 6 and 12 rows.

 

 

  1. Write another function called drawLinesWithRowCol() to pass the no of rows and columns as parameters.

Ex: evoid drawLinesWithRowCol (int rows, int cols);

If 3 is passed as the number of rows and 5 as the number of columns, the function should print,

 

  • * * * *
  • * * * *
  • * * * *

 

  1. Call the function created in section e) in your main program and draw a rectangles with 7 rows and 4 columns.

 

  1. Draw the following figure in your program using the functions you have created in previous sections.
    • * * * *
    • * * * *
    • * * * *
    • * * * *
  • * * * *

 

  1. Write a new function to print a rectangle with a given width, height and the character as the parameter. The rectangle should be printed using that character. Call the function in your main program

2