CProject1

Submission Guidelines

Part 1: Hello World - 15 points

Write a C program that will do the following:

>a.out
Enter your name:                ; prompt
World                           ; user input
Hello world, nice to meet you.  ; program output

For this problem, you can get help from anyone.

Part 2: Bitwise XOR - 40 points

You are to implement a program that

  1. inputs a line (from standard in) containing 2 integers separated by one or more spaces.
  2. bitwise XORs the 2 values together.
  3. finds the least significant 7 bits using logical operators.
  4. prints a single line (to standard out) containing an integer representing the 7 least significant bits
  5. loops until Ctrl-D

Remember:

  • You are to XOR integers not characters
  • Your program should input multiple digit numbers and not be restricted to single digits.
  • If I have my test cases in the file test.txt the following should work: ./a.out < test.txt

Program 3: Music Synth

During the Christmas break I was looking at some music software someone wrote. The melody was contained in a compressed file. When I uncompressed it, the file consisted of a single 2 byte integer per line. Each integer represented one note's pitch and duration. The bit structure of the integer is as follows:


    d d d d d d d d    p p p p p p p p 

The p byte represents a notes pitch. Notes are numbered starting with a low C being note 0. The C above that then is represented as 12. For example, the integer 63 (00111111) represents the note 63. The d byte represents the duration of the note in 16th notes. For example, 00000100 represents a note whose duration is 4 sixteenth notes. You are to write a program that takes as input a sequence of lines as described above and outputs (to standard out) the note number and duration separated by a tab. For example, if 1087 is input you are to output

63 4

meaning Eb played for 4 sixteenth notes.

If I have my test cases in the file test.txt the following should work: ./a.out < test.txt

Further examples are as follows

24639	63	96
1085	61	4
571	59	2
576	64	2
575	63	2
580	68	2
578	66	2
582	70	2
3140	68	12
582	70	2
583	71	2
2628	68	10
583	71	2
592	80	2
590	78	2
1099	75	4
1602	66	6
580	68	2
587	75	2
585	73	2
2118	70	8
2107	59	8
4159	63	16
1085	61	4
571	59	2
576	64	2
575	63	2
582	70	2
580	68	2
5720	88	22
1111	87	4

Again, if I have a file test.txt containing

24639
1085	
571
576
575	

And execute

./a.out < test.txt > output.txt

The output file should contain

63	96
61	4
59	2
64	2
63	2

Comments

Agenda

xor does not return correct results for example, when given 130 and 6 your program should return 2. Other than that everything looks good.

Conroe

xor should output least significant 7 bits.

Egypt

bitxor does not compile:

bitxor.c: In function ‘main’:
bitxor.c:14: error: ‘z’ undeclared (first use in this function)
bitxor.c:14: error: (Each undeclared identifier is reported only once
bitxor.c:14: error: for each function it appears in.)

synth only produces correct output for one line.

Kentsfield

music program does not handle test file correct and does not terminate.

Yorkfield

music program does not terminate at end of input.