K
kamkwokho
Could any answer following questions as many as you can.
ii) Write a C shell script convertmin which will read in a number, thought
of as representing minutes, and print out the number of hours/minutes it
represents so:
[Note: you are required to check exception cases: such as negative number,
whether the input is numeric,etc]
$ convertmin
Enter a number of minutes:
128
Result
128 minutes is 2 hours and 8 minutes
iii) Write a C shell script in2ftcm which uses arithmetic expansion to
convert from inches to meters and centimetres, rounded down to the nearest
whole number of centimetres. Input should be a whole number of inches, and
you may assume.
Explain your algorithm to determine the inches from the centimetres input.
iv) Write a C shell script , test your script on your ucourse server, called
greetings which will print out one of Good morning, Good afternoon or Good
evening depending on the time of day. [Hints: You can use the output of date
and pattern matching]. (
Question 3
In C program compilation process, you have seen a lot of terminologies such
as preprocessor,
complier, object code, linker, and executable file. Describe the functions
of these
terms in a C program compilation process.
Question 4
(a) Write a C shell script which will read the first 250 lines of a given
text file and store it into a new file. You can assume the given file has
more than 500 text lines.
(b) Write a C program which will read the first 250 lines of a given text
file and store it into a
new file. You can assume the given file has more than 500 text lines.
You are required to create a new file and keep
the original file unchanged.]
Question 5
In this question you will need to write a simple network related C program.
Follow the
instructions as much as you can and if you are in doubt consult your tutor
or post your query
in your group BBS.
Background: On unix system, one quick way to find out who has accessed the
system is to
use the ¡¥last¡¦ command . For example, you can find out the last 500
entries using
$last ¡V500
Or you can save the output onto a file using the redirect command
$last ¡V500 > last500.log
WARNING, do not simply type the last command without the ¡V500 option,
otherwise
your command will use up a lot of CPU resource and slow your programming
work!
Expected outcome:
Create the last500.log file and then write a C program to read the
last500.log file. Your
program should then delete all the entries that contain ouhk¡¦. You should
rename the output
file as non-ou.log.
ii) Write a C shell script convertmin which will read in a number, thought
of as representing minutes, and print out the number of hours/minutes it
represents so:
[Note: you are required to check exception cases: such as negative number,
whether the input is numeric,etc]
$ convertmin
Enter a number of minutes:
128
Result
128 minutes is 2 hours and 8 minutes
iii) Write a C shell script in2ftcm which uses arithmetic expansion to
convert from inches to meters and centimetres, rounded down to the nearest
whole number of centimetres. Input should be a whole number of inches, and
you may assume.
Explain your algorithm to determine the inches from the centimetres input.
iv) Write a C shell script , test your script on your ucourse server, called
greetings which will print out one of Good morning, Good afternoon or Good
evening depending on the time of day. [Hints: You can use the output of date
and pattern matching]. (
Question 3
In C program compilation process, you have seen a lot of terminologies such
as preprocessor,
complier, object code, linker, and executable file. Describe the functions
of these
terms in a C program compilation process.
Question 4
(a) Write a C shell script which will read the first 250 lines of a given
text file and store it into a new file. You can assume the given file has
more than 500 text lines.
(b) Write a C program which will read the first 250 lines of a given text
file and store it into a
new file. You can assume the given file has more than 500 text lines.
You are required to create a new file and keep
the original file unchanged.]
Question 5
In this question you will need to write a simple network related C program.
Follow the
instructions as much as you can and if you are in doubt consult your tutor
or post your query
in your group BBS.
Background: On unix system, one quick way to find out who has accessed the
system is to
use the ¡¥last¡¦ command . For example, you can find out the last 500
entries using
$last ¡V500
Or you can save the output onto a file using the redirect command
$last ¡V500 > last500.log
WARNING, do not simply type the last command without the ¡V500 option,
otherwise
your command will use up a lot of CPU resource and slow your programming
work!
Expected outcome:
Create the last500.log file and then write a C program to read the
last500.log file. Your
program should then delete all the entries that contain ouhk¡¦. You should
rename the output
file as non-ou.log.