====== Lab03 - Types and arrays ======
==== Makefile ====
* Variables
* Many built-in variables for system tools like RM for rm -f, CC for gcc or CXX for g++
VAR := $(CC)
VERSION = $(CXX) --version
CFLAGS ?= -Wall -Werror
LIBS += -lm
define ARR
* Then we can write our Makefile as
LIBS += -lm
OUTNAME := output
SRC += main.c
all:
$(CC) $(SRC) -o $(OUTNAME) $(LIBS)
clean:
$(RM) $(OUTNAME)
==== Data types ====
* Basic data types
* _Bool
* char < short < int < long < long long
* unsigned char < unsigned short < unsigned < unsigned long
* float < double < long double
* Precise data types (defined in )
* int8_t
* int16_t
* int32_t
==== Arrays and pointers ====
* No checking of the out-of-bound indexing
* Fixed size known at the compile time
int arr[10];
int n = 5;
char vars[n];
float coeffs[] = {4.2, 0.12, 8.7773};
* Arrays are passed to functions as pointers
==== Tasks ====
- Write a program that will perform a dot product of two vectors (represented as 1D arrays)
- 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)
- 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.
- Write a program that reads a 5x5 array of integers and then prints the row sums and the column sums.