Basic Programming in C
- Github Classroom Link: https://classroom.github.com/a/tL-Hlaui
- Clone the repository to your computer (or open it in repl.it)
Part 1: From Java to C
In the part1
directory, you’ll find three Java programs, prob1.java
, prob2.java
, and prob3.java
. Rewrite each of these programs into C programs that have the same output (either to stdout
or stderr
) for any given input.
Part 1 Requirements:
Your submission in thepart1
directory must include
prob1.c
: C version ofprob1.java
prob2.c
: C version ofprob2.java
prob3.c
: C version ofprob3.java
Part 2: Fix the errors in the following C programs
In the part2
directory, you’; find three C programs whoops.c
, mybad.c
and thatsgottahurt.c
. Each of these programs fail to compile. Fix the programs errors such that the compile and run correctly. Note you shouldn’t change the functionality of the programs, just the compilation errors
Part 2 Requirements:
Your submission in thepart2
directory should include corrected version of the following files
whoops.c
: C version ofprob1.java
mybad.c
: C version ofprob2.java
thatsgottahurt.c
: C version ofprob3.java
Additionally, add a file to the
part2
directory calledfixes.md
where you describe how each of the programs compilation error was corrected.
Part 3: Hour Glass
In part3
directory. complete the program that prints hourglass patterns of *
’s of different widths. Here’s some sample output, and, yes, you should print the row numbers. They will help you debug :)
$ ./hourglass
Enter hourglass width:
6
****** 6
**** 4
** 2
** 2
**** 4
****** 6
$ ./hourglass
Enter hourglass width:
7
******* 7
***** 5
*** 3
* 1
*** 3
***** 5
******* 7
$ ./hourglass
Enter hourglass width:
30
****************************** 30
**************************** 28
************************** 26
************************ 24
********************** 22
******************** 20
****************** 18
**************** 16
************** 14
************ 12
********** 10
******** 8
****** 6
**** 4
** 2
** 2
**** 4
****** 6
******** 8
********** 10
************ 12
************** 14
**************** 16
****************** 18
******************** 20
********************** 22
************************ 24
************************** 26
**************************** 28
****************************** 30