Monday, January 30, 2012

50 Programs for software engineers looking for jobs

Loops and Variables
  1. Write a program to swap two numbers without using an additional variable.
    Solution : vb.net
  2. Write a program to find the biggest number in n numbers without using arrays.
    Solution : vb.net
  3. Write a program to find the second biggest number in n numbers without using arrays.
  4. Write a program to find the smallest number in n numbers without using arrays.
  5. Write a program to find out m * n without using the * operator.
  6. Write a program to find out m / n without using the / operator.
  7. Write a program to find out m ^ n without using the ^ operator.
  8. Write a program to find out m % n without using the % operator.
  9. Write a program to find out the average of n numbers.
  10. Convert a number in String format to integer - Number entered as "1234" should come as 1234 and "1234a" should come as an error.
  11. Write a program to find the factorial of a number.
  12. Write a program to find out 1+2+3+4+...+n
  13. Write a program that sums up the digits of a number until it is a single number
    Eg: 2748303 = 2+7+4+8+3+0+3 = 27 = 2+7 = 9
  14. Write a program that accepts a base ten integer number and outputs the binary, octal and hexadecimal representations of that number.
  15. Write a program that accepts a hexadecimal representation of a number and outputs the decimal representation of that number.
  16. Write a program to print all the prime numbers between m and n where m is less than n.
  17. Write a program to find all the prime factors of a number.
  18. Write a program which reverses the numerals in an integer, that is 326 becomes 623
Patterns
  1. Write a program to print the pascal's triangle. The way to compute any given position's value is to add up the numbers to the position's right and left in the preceding row. For instance, to compute the middle number in the third row, you add 1 and 1; the sides of the triangle are always 1 because you only add the number to the upper left or the upper right (there being no second number on the other side).
                                                        1
                                                   1        1
                                               1        2        1
                                           1       3        3        1
                                      1       4        6        4        1
                                 1        5      10      10       5        1
  2. Write a program that prints
                                *
                           *        *
                       *       *        *
                  *       *        *        *
             *        *        *        *       *  
  3. Write a program that prints
                                *
                           *        *
                       *                 *
                  *                           *  
             *        *        *        *       *  
  4. Write a program that prints
    *   *  *  *  *  *  *   *
    *                            *
    *                            *
    *                            *
    *                            *
    *                            *
    *   *  *  *  *  *  *   *
Arrays
  1. Write a program to find out the median of n numbers.
  2. Write a program to find out the mode of n numbers.
  3. Write a program to sort numbers using bubble sort.
  4. Write a program to sort numbers using quick sort.
  5. Write a program to find the sum of two m x n matrices.
  6. Write a program to find the product of two matrices.
  7. Write a program to find the transpose of a matrix.
Fibanocci Series
  1. Write a program to print the first n numbers of the fibanocci series.
  2. Write a program to print only the first 10 odd numbers in a fibanocci series.
  3. Write a program to print the list of numbers in a fibanocci series that adds up to n.
Strings
  1. Write a program to reverse a string
    - "My name is sudeep" should become "peedus si eman yM"
  2. Write a program to find the length of a string.
  3. Write a program to reverse the words in a string
    -"My name is sudeep" should become "sudeep is name My"
  4. Write a program to display all possible permutations of a given input string
    - if the string contains duplicate characters, you may have multiple repeated results.
    Input should be of the form
    permute string
    and output should be all the combinations of the letters. Here is a sample for the input
    cat cat cta act atc tac tca 
  5. Write a program that takes an integer and displays the English name of that value. You should support both positive and negative numbers.
    Examples:
    10 -> ten 121 -> one hundred twenty one
    1032 -> one thousand thirty two
    11043 -> eleven thousand forty three
    1200000 -> one million two hundred thousand 
  6. Write a program that takes two arguments at the command line, both strings. The program checks to see whether or not the second string is a substring of the first (without using the substr -- or any other library -- function). One caveat: any * in the second string can match zero or more characters in the first string, so if the input were abcd and the substring were a*c, then it would count as a substring. Also, include functionality to allow an asterisk to be taken literally if preceded by a \, and a \ is taken literally except when preceding an asterisk.
  7. Given a pair of words (the first is the correct spelling and the second is the contestant’s spelling of the word) determine if the word is spelled correctly. The degree of correctness is as follows:
    CORRECT if it is an exact match
    ALMOST CORRECT if no more than 2 letters are wrong
    WRONG if 3 or more letters are wrong
  8. Write a program to read a sentence and calculate the average word value for that sentence. Word value is calculated by finding the average of the ASCII values of all of the letters in a word. Average word value is the average of the word values of all of the words in the sentence rounded to the nearest integer. All letters are upper case. Any non-letter characters are not part of the word in which they are located.
    Eg: MY NAME IS SUDEEP
    = (77+89)/2 + (78+65+77+69)/4 + (73+83)/2 + (83+85+68+69+69+80)/6
    = 83 + 72.25 + 78 + 75.67 = 83 + 72 + 78 + 76
    = 309 / 4
    = 77.25
    = 77
  9. To convert a word to Pig Latin, the first letter of the word was moved to the end (after the last letter of the word) and the letters “AY” were added. For example, PIG becomes IGPAY. Write a program to convert a given sentence to pig latin.
    Eg. MY NAME IS SUDEEP.
    In Pig latin : YMAY AMENAY SIAY UDEEPSAY
 Files
  1. Write a program to find the number of lines in a file new line defined as "\n" and the number of words in a file. A word is defined as two patterns of characters separated by one or more spaces.
  2. Count the number of times a word occurs in a file - the word and the location of the file are inputs to the program.
  3. Write a program that will merge two files and give an output of 1 file.
Linked Lists
Note : The format for the node should be a struct containing an integer value, val, and a next pointer to the following node.
  1. Write a program to find out the length of a linked list.
  2. Write a program to find out if the linked list has a loop.
  3. Write a program to print a singly linked list in reverse.
  4. Write a program to reverse the entire linked list in place. By in-place, I mean that no memory can be allocated. The resulting code should be function that takes the head of a list and returns a the new head of the reversed list. 
  5. Write a program to implement push and pop functions in a linked list.
  6. Write a program which can insert a new node at any index within a list. The program may specify any index in the range [0..length], and the new node should be inserted so as to be at that index. The index is calculated as the position from the beginning of the linked list.

You do what you are

In the 2001 movie Along came a spider, there is an interesting quote by Morgan Freeman where he says "You do what you are" and the...