Lab 7 – 2017

Slides [ EST ] [ ENG ]
Coding style: [ Link ]
Debugging 101: [ Link ]


Task 1 (0.5p)

Copy the following code into your IDE and modify it so that:

  • it prints out the array of integers it created
#include <stdio.h>

#define ARRAY_SIZE 25

int function(int input);

int main() {
    int array[ARRAY_SIZE] = {0};

    for (int i = 0; i < ARRAY_SIZE; i++) {
        array[i] = function(i);
    /* Your code goes here*/

    return 0;

int function(int input) {
    return (input * (input - 1));

Task 2 (1p)

Create C program based on the decimal to binary converter algorithm.

Task 3 (0.5p) [ optional ]

Create a program in C, which meets following requirements:

  • Declare at least three different integer variables and initialise them with any numbers.
  • Compare and print the integer, which is bigger.
  • Calculate the sum and print it out.

Task 4 (0.5p) [ optional ]

  • Create a string (array of characters) which contains your full name!
  • There’s a catch though. all array values must be referred to as numbers not characters like ‘A’, or ‘k’.  (those are 65, and 107 respectively).
    • Characters are really just numbers, that your tools know how to interpret according to the chart in the ASCII table [ Link ].
    • See what happens: printf(“%c”, 97);
  • Next, print that string! See if you can print it backwards too.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.