No Description

Marina Barsky 9f6a6b1628 Update 'README.md' 1 year ago
.gitignore d5d4725a9d Initial commit 1 year ago
01.pointers1.c 31dfc9cfdc Update '01.pointers1.c' 1 year ago
02.pointers2.c 17611ea47c added pointers2 1 year ago
03.memory1.c 8b5cf5b097 added memory1 1 year ago
04.memory2.c dd4ee4183b Update '04.memory2.c' 1 year ago
05.strings1.c 6a79839e39 source files 1 year ago
06.strings2.c 96b23a854a source files 1 year ago
07.structs1.c 8056e41fc7 Update '07.structs1.c' 1 year ago
08.structs2.c fb88521515 Update '08.structs2.c' 1 year ago
09.files1.c b91914fa7f source files 1 year ago
10.files2.c bccfd02e99 source files 1 year ago
11.linkedlists1.c 69fa21bcce source files 1 year ago
12.linkedlists2.c 2fa514986c source files 1 year ago
13.fork1.c cfd9d15a26 Update '13.fork1.c' 1 year ago
14.fork2.c 02ff6d4a57 Update '14.fork2.c' 1 year ago
15.signals1.c cada51811e Update '15.signals1.c' 1 year ago
16.signals2.c d83d5c6d9e Update '16.signals2.c' 1 year ago
17.sorting1.c 00248dd329 Update '17.sorting1.c' 1 year ago
18.sorting2.c e9e8e814c3 Update '18.sorting2.c' 1 year ago
19.bits1.c eb29f6176d source files 1 year ago
20.bits2.c f6e8e1dc6e source files 1 year ago
LICENSE d5d4725a9d Initial commit 1 year ago
README.md 9f6a6b1628 Update 'README.md' 1 year ago

README.md

Preparation for final exam

You need to do at least 820 questions correctly. Out of these questions 3 should be from Strings, Files and Linked Lists - one from each.


Pointers

[01.pointers1.c]

Find out (add code to print out) the address of the variable x in foo1, and the variable y in foo2. What do you notice? Can you explain this? Add your explanation directly to this README file:

[02.pointers2.c]

Find and eliminate all code that generates Segmentation Fault.


Memory

[03.memory1.c]

[04.memory2.c]

Read code in files 03.memory1.c and/or 04.memory2.c. Then compile code using: gcc -g -o test [file.c], and run valgrind command to check for memory problems:

valgrind –tool=memcheck ./test
Continue fixing the code until no more errors can be identified by valgrind.


Strings

[05.strings1.c]

Write a function convert whose first parameter is an array of strings and second parameter is the number of elements in this array.

Your function should return a string that is the reverse of a longest string in the array (any longest will do in the case of a tie) or NULL if the array was empty. You must not change the strings in the array. You may assume all the strings in the array are null-terminated.

[06.strings2.c]

Write a function that converts an integer number into a C-string (null-terminated character array) and returns this string. Add each digit to the resulting string separately, do not use sprintf.


Structs

[07.structs1.c]

Try to compile and run 07.structs1.c. Fix all errors and memory problems and try again.

[08.structs2.c]

Complete the code according to the instructions in file 08.structs2.c.


Files

[09.files1.c]

Write a program last that prints the last n lines of its text input. The input is in a file with the file name specified as a command-line argument. By default n should be 5, but your program should allow an optional argument so that ./last n prints out the last n lines, where n is any integer.

Your program should make the best use of available storage. It cannot load and store the entire file content because the file is presumed to be too big.

[10.files2.c]

Write a C program to count occurrences of a word in file. The word is provided as a command-line argument.


Linked lists

[11.linkedlists1.c]

You have two numbers represented by a linked list, where each node contains a single digit. The digits are stored in reverse order, such that the 1’s digit is at the head of the list. Write a function that adds the two numbers and returns the sum as a linked list.

[12.linkedlists2.c]

Write a sortedinsert() function which given a list that is sorted in increasing order, and a single node, inserts the node into the correct sorted position in the list.


Fork, pipe

[13.fork1.c]

Compile and run 12.fork1.c. What is this program doing? If you think that something is wrong with it, fix it.

[14.fork1.c]

Answer the following questions related to the program in file 14.fork1.c.

  • How many times «Hello» is printed on the screen?
  • Draw the tree of processes: parent -> child

Signals, sockets

[15.signals1.c]

Write a program that prints its process id, and then runs an infinite loop. When the process receives an interrupt signal, it should print «Hello world». After testing that you cannot terminate the program with Ctrl+C, use process id to hard kill it.

[16.signals2.c]

Finish setup of unix socket server in file 16.signals2.c.


Sorting 1

[17.sorting1.c]

Using qsort and function pointers, sort list of persons first by the last name, and then, in case of a tie, by the first name.

[18.sorting2.c]

Using qsort and function pointers sort an array of points by the euclidean distance from Point(0,0).


Bits

[19.bits1.c]

Write a C program to input any number from user and find highest order set bit of given number using bitwise operators.

Example

Input: 22

Output:
Highest order set bit in 22 is 4.

[20.bits2.c]

Write a C program which takes 2 chars as an input, scans their bits from left to right and finds the first position where their bits are different.

Example:

Input: 12, 14.

Output: 
The first different bit is at position 6 from the left.