Assignment 4
Assignment 4
1. Write a program to compute factorial and GCD using recursion. 2. Write a menu driven application that performs the functions of a calculator. The inputs from the user should be validated and error messages in case, inputs are not valid, should be displayed of multiplication, division, factorials (use recursion) and squares. Modularize the code wherever possible. 3. Write a program to reverse a string using pointers 4. Write a program that will open a file and report on the number of lines, characters, and words in a file. Have the name of the file to be opened appear as a command line argument. // optional // Write a program, which will delete only odd numbers from a linked list of integers. 5. Write a program to remove trailing blanks and tabs from each line of input, and to delete entirely blank lines.
6. Write a C program to calculate factorial of a number. Factorial function has to be written as a multiline macro 1.Develop a program that reads a file containing a list of numbers, and then writes two files, one with all numbers divisible by three and another containing all the other numbers 2.Take one of your previous programs and run it using the interactive debugger to examine several intermediate values 3.Develop a program that counts the number of bits in a character array. Optimize it through the use of register integer variables. Time it o several different arrays of different sizes. How much time does you save? 4.Try examples by embedding assembly code in C and observe the performance 7. Write a program that will open a file and report on the number of lines, characters, and words in a file. Have the name of the file to be opened appear as a command line argument. 8. Write a program to remove trailing blanks and tabs from each line of input, and to delete entirely blank lines. 9. Write a program to remove all the comments from a C program. 10. Develop a program that reads a file containing a list of numbers, and then writes two files, one with all numbers divisible by three and another containing all the other numbers 11. Write a program which reads a line of characters. Each character entered from the keyboard is tested to determine its case, and is then written to the data file in opposite case. Display the contents of the file. Also use ftell and fseek to determine 15 the current file position and to change the file position 12. Write an interactive, file-oriented C program that will maintain a list of names, addresses and telephone numbers in alphabetical order (by last names). Process the information associated with each name as a separate record, represent each record as a structure. Include a menu that will allow the user to select any of the following features: a. Add a new record b. Delete a record c. Modify an existing record d. Retrieve and display an entire record for a given name e. Generate a complete list of all names, addresses and telephone numbers f. End the computation Be sure to rearrange the records whenever a new record is added or a record is deleted, so that the records are always maintained in alphabetical order. Utilize a linear linked list. Also use ftell and fseek wherever required
13. Write a program that will generate a data file containing a list of countries and their corresponding capitals. Write interactive code which will access the above created data file to perform the following operations a. Determine the capital of a specified country b. Determine the country whose capital is specified c. Terminate the programme 14. Write a program to embed assembly language code in C program Data Structures: f the masking operation is selected, prompt the user for the type of operation (bitwise and, bitwise exclusive or, or bitwise or) and then a (hexadecimal) value for the mask. If the bit shifting operation is selected, prompt the user for the type of shift (left to right), and then the number of bits
15. Write a C program that will illustrate the equivalence between a. Shifting a binary number to the left n bits and multiplying the binary number by 2n b. Shifting a binary number to the right n bits and dividing the binary number by 2n. Choose the initial binary number carefully, so that bits will not be lost as a result of the shifting operation