Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                

Systems Software/Programming - Lab Manual

Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Systems Software/Programming – Lab Manual

______________________________________________________________________________

Lab 3 – C Revision

Write C program for each of the problem below. After executing each of the C
program, you will need to capture the output in text file format.
C program file will be named as StudentID_Lab3_x.c
Text file with output captured will be names as StudentID_Lab3_x.txt

1. Write c program StudentID_Lab3_1.c with:


fib() function generates the Fibonacci series of a given number n.
fact() function generates factorial of a given number n
numlen() function finds the length of a given number n
Using array of function pointers (*functions[]) call each of these functions
respectively for a menu driven program. E.g. fib() is called when user selects 1, fact()
for 2 and numlen() for 3, exit program when user enters 0
main() function implements menu and calls the respective functions as per menu
selection by user

2. Write a c program StudentID_Lab3_2.c which implements recursive function


recursive_strlen(char *str) to find the length of the string recursively which is called
from main function to get the length of the string.

3. Write a c program StudentID_Lab3_3.c for this problem. You are given a task to
keep track of all the programs running on a computer. You are required to
implement a doubly linked list (non-circular) where in each node will store the
following program information and will have pointer to the next and previous
nodes. There will also be head and tail pointers pointing to first and last nodes
respectively.

struct program {
int prog_id; // program id
char prog_name[50]; // name of the program including full path
char uid_executing[25]; // user id who is executing the program
uint64_t start_time; // process start time using gettimeofday() system call
uint64_t time_elapsed; // time in microsecond program has been executing
int prog_status; // submitted, running, finish
}

main() function will accept following menu options:


1. Add new program for which user will enter prog_name, uid_executing. Initial
status is submitted
2. A user entered program started running which will change status from
submitted to running
3. A user entered program completed which will change status from running to
completed
4. Update time-elapsed for all programs
5. Remove all the completed programs from the list
6. Print all the programs information
7. Exit

Submission:
StudentID_Lab3.zip with total 6 files (3 C program files + 3 captured output text
files)

You might also like