Programming contests

20 Programming Exercise for Beginners

January 1, 2019 12:00 AM – December 31, 2019 12:00 AM

Multiplication Table

Create a program that draws a multiplication table containing the numbers received from the standard input.

Input Specification

The input consists of positive integers. The integers are separated by newline characters. The length of the input data is not restricted, but it is guaranteed that the square of the largest integer is not greater than the numbers we can store in a variable of type int.

Sample Input

  1. 2
  2. 4
  3. 8
download as text file

Output Specification

The output consists of a multiplication table where each line is terminated by a newline and the numbers are separated by spaces. The ith number of the jth line contains the product of the ith and jth integers of the input. The table contains no headings.

Output for Sample Input

  1. 4 8 16
  2. 8 16 32
  3. 16 32 64
download as text file

Hints and Guide

Because of the length of the input was not specified, the best solution is to create a linked list to store the input data.

The implementation of a linked list requires a record type with two fields: an integer and a pointer to the next item. We will use the linked list as a queue, hence both the first and the last member should be referenced with pointers.

One possible solution is available in: main.c.

Acknowledgement This work was supported by the construction EFOP-3.4.3-16-2016-00021. The project was supported by the European Union, co-financed by the European Social Fund.
University of Debrecen; Faculty of Informatics; v. 03/01/2019