Table of Contents

Lab03 - Types and arrays

Makefile

  VAR := $(CC)
  VERSION = $(CXX) --version
  CFLAGS ?= -Wall -Werror
  LIBS += -lm
  define ARR
  

  LIBS += -lm
  OUTNAME := output
  SRC += main.c
  
  all:
	$(CC) $(SRC) -o $(OUTNAME) $(LIBS)
	
  clean:
	$(RM) $(OUTNAME)
  

Data types

Arrays and pointers

int arr[10];

int n = 5;
char vars[n];

float coeffs[] = {4.2, 0.12, 8.7773};

Tasks

  1. Write a program that will perform a dot product of two vectors (represented as 1D arrays)
  2. Write a program which reads a string with a length given by the user and counts all vowels (a, e, i, o, u) in a separate function. Hint: use function
    char *fgets(char *s, int size, FILE *stream)
  3. Write a program which creates an array with variable length based on the user input. Then it reads the desired number of integers and then outputs their cumulative sum.
  4. Write a program that reads a 5×5 array of integers and then prints the row sums and the column sums.