Dynamic Array in C
Snow Howler is the librarian at the central library of the city of HuskyLand. He must handle requests which come in the following forms: 1 x y : Insert a book with y pages at the end of the xth shelf. 2 x y : Print the number of pages in the yth book on the xth shelf. 3 x : Print the number of books on the xth shelf. Snow Howler has got an assistant, Oshie, provided by the Department of Education. Although inexperienced, Oshie can handle all of the queries of types 2 and 3. Help
View Solution →Calculate the Nth term C
This challenge will help you learn the concept of recursion. A function that calls itself is known as a recursive function. The C programming language supports recursion. But while using recursion, one needs to be careful to define an exit condition from the function, otherwise it will go into an infinite loop. To prevent infinite recursion, if ... else statement (or similar approach) can be used where one branch makes the recursive call and other doesn't. void recurse() { .....
View Solution →Sorting Array of Strings C
To sort a given array of strings into lexicographically increasing order or into an order in which the string with the lowest length appears first, a sorting function with a flag indicating the type of comparison strategy can be written. The disadvantage with doing so is having to rewrite the function for every new comparison strategy. A better implementation would be to write a sorting function that accepts a pointer to the function that compares each pair of strings. Doing this will mean on
View Solution →Permutations of Strings C
Strings are usually ordered in lexicographical order. That means they are ordered by comparing their leftmost different characters. For example, abc < abd because c < d. Also z > yyy because z > y. If one string is an exact prefix of the other it is lexicographically smaller, e.g., gh < ghij. Given an array of strings sorted in lexicographical order, print all of its permutations in strict lexicographical order. If two permutations look the same, only print one of them. See the 'note' bel
View Solution →Variadic functions in C
Variadic functions are functions which take a variable number of arguments. In C programming, a variadic function will contribute to the flexibility of the program that you are developing. The declaration of a variadic function starts with the declaration of at least one named variable, and uses an ellipsis as the last parameter, e.g. int printf(const char* format, ...); In this problem, you will implement three variadic functions named sum(), min() and max() to calculate sums, minima,
View Solution →