Docsity

CS 228 Network Programming Assignment 1 at Northern Michigan University - Prof. Andrew A. , Assignments of Computer Science

Toggle sidebar
bg1
NORTHERN MICHIGAN UNIVERSITY
CS 228-01-10W
NETWORK PROGRAMMING
Program 1
Due: Monday 25 January 2010 2:00 P.M. EST
Create a directory called “PG1” at the top level of your shared folder. Put all your materials
pertaining to this assignment in PG1. Put a make file called “Makefile” in this folder. The make
file should correctly compile all of the programs described below.
1. Write a program in C++ that accepts an integer on the command line. The program should
return 1 if the integer is prime and 0 if the integer is not. The command line is guaranteed to
contain a positive integer within the valid range of acceptable integers; there will be no dirty
tricks. Your program should not read or write anything. This program must be called
“pg1-1a.cc” and the executable should be called “pg1-1a”.
Write a second program in C++ that asks the user for an integer. It should read in the integer and
then execute the first program on that integer. That first program should then return whether the
integer was prime. The second program should then print out an appropriate text string
indicating whether the integer so entered was prime. This program should be called “pg1-1b.cc”,
and the executable should be called “pg1-1b”.
Note: The second program does all the input and output. The first program does all the
computation.
2. Write a program in C++ that opens a pipe and forks a copy of itself. The parent should then
ask the user for a string. The user should type in a string and send that string down the pipe to
the child. The child should reverse the case of all letters in the string (uppercase letters become
lowercase; lowercase letters become uppercase; nonalphabetic characters do not change) and
send it back to the parent. The parent should print it out. In other words, the parent does all the
reading and writing. The child does all of the work. The program should be called
“pg1-2.cc”,and the executable should be called “pg1-2”
Neither of these programs should use the “system” command. Use low-level calls only.
When you are ready for your program to be graded, put a (possibly empty) file in your PG1
folder called “DONE”. I will remove this file after I grade your submission.

Partial preview of the text

Download CS 228 Network Programming Assignment 1 at Northern Michigan University - Prof. Andrew A. and more Assignments Computer Science in PDF only on Docsity!

NORTHERN MICHIGAN UNIVERSITY

CS 228-01-10W

NETWORK PROGRAMMING

Program 1

Due: Monday 25 January 2010 2:00 P.M. EST

Create a directory called “PG1” at the top level of your shared folder. Put all your materials pertaining to this assignment in PG1. Put a make file called “Makefile” in this folder. The make file should correctly compile all of the programs described below.

  1. Write a program in C++ that accepts an integer on the command line. The program should return 1 if the integer is prime and 0 if the integer is not. The command line is guaranteed to contain a positive integer within the valid range of acceptable integers; there will be no dirty tricks. Your program should not read or write anything. This program must be called “pg1-1a.cc” and the executable should be called “pg1-1a”.

Write a second program in C++ that asks the user for an integer. It should read in the integer and then execute the first program on that integer. That first program should then return whether the integer was prime. The second program should then print out an appropriate text string indicating whether the integer so entered was prime. This program should be called “pg1-1b.cc”, and the executable should be called “pg1-1b”.

Note: The second program does all the input and output. The first program does all the computation.

  1. Write a program in C++ that opens a pipe and forks a copy of itself. The parent should then ask the user for a string. The user should type in a string and send that string down the pipe to the child. The child should reverse the case of all letters in the string (uppercase letters become lowercase; lowercase letters become uppercase; nonalphabetic characters do not change) and send it back to the parent. The parent should print it out. In other words, the parent does all the reading and writing. The child does all of the work. The program should be called “pg1-2.cc”,and the executable should be called “pg1-2”

Neither of these programs should use the “system” command. Use low-level calls only.

When you are ready for your program to be graded, put a (possibly empty) file in your PG folder called “DONE”. I will remove this file after I grade your submission.