Thread: Any "recommended" C programs to be used in a programming contest? Please help.

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #5
    Deathray Engineer MacGyver's Avatar
    Join Date
    Mar 2007
    Posts
    3,210
    I'm not sure how easy or hard you actually mean. This is for freshmen, so I don't think you want it too difficult. You said you wants loops, functions, and arrays.... I'll try to give you a range of topics, but I'm not sure if I'm classifying them according to their true level of difficulty. It should get you started, though.

    Super Easy:

    • Implement the C library function strcpy().
    • Write a function that accepts an unsigned int and returns the factorial of that number.
    • Write a function that accepts two unsigned integers and returns the result of their multiplication, however, direct multiplication and division (ie. * and /) are NOT allowed.


    Easy:

    • Write a program that continuously asks the user for a string. If the string matches "exit", then the program quits. If the string is a palindrome, the program should print "Palindrome". If the string is NOT a palindrome, the program should print the index on both sides where the characters does NOT match. (ie. "exit" causes exit. "radar" causes "Palindrome". "123541" produces "1 4" because string[1] and string[4] do NOT match.)
    • Write a function that accepts two signed integers a and b, and returns a % b, except the % operator may NOT be used. [Care to get exactly the same result as % could be part of the challenge.]
    • Write a program that accepts a float/double and converts it into a reduced fraction (ie. 12.25 would be 12 1/4). [We had the opposite question asked here on this forum.]


    Medium:

    • Write a program that reads in a set number of bank account records, sorts them by customer name, and prints them. Bank account records are made up of the following items: 8-digit integer account ID, customer name no longer than 30 chars, and the amount in the account. If customer names are the same between two accounts (because the customer has multiple accounts), the accounts in question are further sorted by their ID. Accounts are printed with all information.
    • Write a program that reads in a hexadecimal integer number and prints back it's positive and negative value on that system. (ie. On a 32-bit 2's complement system, 0xFFFFFFFF will result in 4294967295 and -1.). If the number is positive whether taken as signed or unsigned, multiply the number by -1. [This is rather easy. Some addition to this challenge with regard to signed and unsigned numbers would be good here.]
    • Write a program that reads in a set number of signed integers, and then divides them all by their GCD.


    Hard:

    • Implement a power function that takes in two signed integers a and b, and returns the result of a raised to the power of b as a double. Note: Both a and b can independently be negative. Write a program to accept two signed integers and test the function.
    • Write a program that reads in 5 signed integers that form a pattern where subsequent numbers are either greater than or less than their previous number by a certain unknown integer value. The program must output the next number in the pattern. For example, if the numbers 1, 2, 3, 4, and 5 are the input, then the output is 6. If the input is 1, 3, 5, 7, 9, then the output is 11. If the output is -3, -6, -9, -12, -15, then the output is -18. [This is probably easier than intended. To make it more difficult and probably at a more appropriate leve of difficultyl, allow for multiplication and division to affect the numbers instead of just addition and subtraction. To further complicate it, allow for the unknown factor to be a floating point number instead of an integer. To further complicate the challenge, allow for a complex patter made up of more than one simple pattern.]
    • Write a program that reads in two 3x3 matrices (in the form of 9 signed integers each), and prints the results of addition between the two matrices as well as the result of the dot product between the two matrices.


    Super Hard:

    • Write a bigint implementation in a program where the user may enter two 100-digit integers and request addition and or subtraction between those two numbers. [The implementation should be able to handle overflow with addition, and underflow with subtraction.]
    • Write a function that reads input from stdin until a newline or EOF is reached in the stream. The entire string should be stored inside a dynamically sized block of memory and returned by the function. The returned char * should be printed by the caller and then free()ed.
    • Write a program that is able to read an arbitrary amount of unsigned integers ended with an entry of -1. After reading in all of the integers, the program must calculate the mean, mode, median, variance and standard deviation of that set of numbers.
    Last edited by MacGyver; 12-10-2007 at 11:48 AM. Reason: Fixed error in palindrome example, clarified another.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Expression Evaluator Contest
    By Stack Overflow in forum Contests Board
    Replies: 20
    Last Post: 03-29-2005, 10:34 AM
  2. Obfuscated Code Contest
    By Stack Overflow in forum Contests Board
    Replies: 51
    Last Post: 01-21-2005, 04:17 PM
  3. WANTED: Contest Master
    By kermi3 in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-23-2003, 10:15 PM