Project Definitions 5
Project Definitions 5
Instructions:
1) Please note the word in italic is to be replaced by the actual value. Where ever used, file
indicates file name.
2) Please write the algorithm in a text file and submit it for review. This is to validate that you have
correctly understood the problem statement. This also results in your logic getting reviewed
before you start coding
3) The project to be:
a) coded in C Language in Linux environment.
b) A directory has to be creates in your home directory (/home/your_user_id) and the project
related files have to be placed in that directory. Ensure the source files have the .c extension
and header files .h extension. Also the names of the file should have no spaces in them.
c) use the coding guidelines indicated in the document “Coding standards.pdf” while writing
the programs. THIS IS VERY IMPORTANT.
d) write the problem statement as a comment at the top of the file.
4) Submitted programs should compile with no ERRORs or WARNINGS with gcc compiler on
Linux Ubuntu 22.04.
5) Test your programs before submitting.
6) The last date for submission is _________________
1. Project 1
Project has to do the following:
a. Read the complete contents of a file specified on the command line as
follows:
./a.out file (e.g ./a.out words.txt)
b. Count the number of words in the file and display on the screen:
word count = …
c. Keep a count of the various lengths of each word in the file.
d. Print a vertical histogram of the length of words using “*” character as
the bar in the following manner:
example: if the number of 1, 2 and 3 letter words are as follows:
1 letter word = 2
2 letter word = 4
3 letter word = 7
4 letter word = 0
5 letter word = 3
then, display the histogram in the following manner:
*
*
*
* *
* * *
* * * *
* * * *
2. Project 2
Project has to do the following:
a. Read the complete contents of a file specified on the command line as
follows:
./a.out file (e.g ./a.out lines.txt)
b. Count the number of lines in the file, and display it on the screen:
line count = …
c. Print all lines less than 80 characters.
d. Fold all lines greater than 80 characters into 2 or more lines ensuring
that:
i. all lines are less than 80 characters
ii. split the line after last non-blank character that occurs before
the 80th character.
3. Project 3
The project has to do the following:
a. Take a filename as command line argument as shown:
./a.out file (e.g. ./a.out students.txt)
The file contains the name of the student and the marks in science and
maths as shown below:
student-name1 sceince-marks1 maths-marks1
student-name2 sceince-marks2 maths-marks2
…
sample input:
Annie 74 85
Adam 84 75
…
sample output:
Annie:
Science = 74
Maths = 85
Adam:
Science = 84
Maths = 75
…
…
Average marks:
Science: 51.388889
Maths: 54.000000
4. Project 4
The project has to do the following:
a. Take a set of options and filename as command line argument:
./a.out [-w|-c|-l] file
where:
-w : indicates calculate word count
-c : indicates calculate character count
-l : indicates calculate line count
Please note –w, -c, -l can be optional or multiple options can also be
specified as this:
./a.out ex2.c
./a.out –wlc ex2.c
./a.out –w –l -c ex2.c
./a.out –wl ex2.c
./a.out –w ex2.c
Input:./a.out –w ex2.c
Output: 73 ex2.c
e. Please display the appropriate messages when sufficient arguments are not
specified. Error messages to be always written to STDERR.
Example: when the following command is given with no other command
line arguments:
./a.out
Print: usage: ./a.out [-w | -c | -l] <file_name>
5. Project 5
"RXSR" is a 32 bit register at offset 0. It is made up of the following fields:
Please write a test application with main function that tests the register field
read and write for the register "RXSR".
To help you in this task, the following files have been provided in
lib_folder.zip:
6. Project 6
"ULCR" is a 32 bit register at offset 1. It is made up of the following fields:
Please write a test application with main function that tests the register field
read and write for the register "ULCR".
To help you in this task, the following files have been provided in
lib_folder.zip:
7. Project 7
Read lines from a file and store them in a two dimensional char array created
using a char **. The file will be specified as a command line argument.
(example:./a.out file)
If the file has 24 lines or less number of lines, display the lines and wait on the
colon “:” prompt.
8. Project 8
Write a program detab, that replaces all the tabs in an input file (specified as a
command line argument) with 4 blank spaces.
9. Project 9
Write a program remove all comments from a C program. There will be no
nested comments (comment inside a comment). Make sure both multi-line
comments (/* … */) and single line comments (// …) are handled.
10. Project 10
Write a program to check a C program to see whether there are any unmatched
braces (curly brackets). Remember that there can be braces inside a pair of
braces. The C program file will be provided as a command line argument
11. Project 11
Write a program to check a C program to see whether there are any unmatched
square brackets. The C program file will be provided as a command line
argument
12. Project 12
Write a program to check a C program to see whether there are any unmatched
parentheses. Remember that there can be parentheses inside a pair of
parentheses. The C program file will be provided as a command line argument
13. Project 13
Write a C program to implement all arithmetic operations on complex numbers.
It should be a menu driven program that displays options for all the arithmetic
operations and also for exiting the program.
The option entered by the user should be used as an index into an array of
function pointers that contains the addresses of the arithmetic operation
functions. So the arithmetic operation will be carried out using these function
pointers.
NOTE: Remember that complex numbers may be entered in rectangular or polar form and
the program should keep track of the format in which the complex number has been entered.