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 →

Querying the Document C

A document is represented as a collection paragraphs, a paragraph is represented as a collection of sentences, a sentence is represented as a collection of words and a word is represented as a collection of lower-case ([a-z]) and upper-case ([A-Z]) English characters. You will convert a raw text document into its component paragraphs, sentences and words. To test your results, queries will ask you to return a specific paragraph, sentence or word as described below. Alicia is studying the C

View Solution →