Sale!

COSC 350 System Software Midterm #1-1 solved

Original price was: $35.00.Current price is: $35.00. $21.00

Category: You will receive a download link of the .ZIP file upon Payment

Description

5/5 - (1 vote)

1. (10 pt) Write a syntax free shell script “task1.sh” that reads sequence of integers on the
command line and calculate odd value sum and display the result. You need send as a
separate file with name task1.sh. Use for loop. Do not use (()) in loop or calculation. Exit
the program with an appropriate error message under the following error condition: if there is
no argument on the command line.
Ex) for ./task1.sh 12 9 21 10 100 23
Output: The sum of odd arguments is 53
2. (10 pt.) Redo problem 1 with compliable C code . You need send as a separate file with
name task2.c. Define your own function (int str_to_int(char*)) to convert a c-string to an
integer (Do not use any library function to convert).
3. (30 pt.) You need write a following compliable program. You need send as a separate file with
name task3.c. Write a C main function that takes one command-line argument, the name of
an input file. The input file contains exactly one integer spread out over a single line of up to
80 characters. For example, the integer 3579 is embedded in the line
az3mqrm5t?7!z*&gqmzt9v. Your program uses system calls to do the following:
a. open and read each character from the input file, accumulating the discovered digit
characters into a character array (c-string). (Do not use isdigit (int c) function to check
number character)
b. Define your own function (int str_to_int(char*)) to convert a c-string to an integer
(Do not use any library function to convert). You can reuse the function from previous
problem.
c. Add 100 to the integer
Define your own function (char *int_to_str (int value)) to convert the sum back to a
c- string (Do not use any c library function to convert).
d. Use a system call write() to write the string to standard output.