Don't Be So Negative!

This is a warmup exercise. It is not compulsory, and may be completed individually or with your lab partner.

Let’s start by creating a lab02 directory and moving into it like so:

$ mkdir lab02
$ cd lab02

Now create and open a new file called negative.c for this exercise.

$ gedit negative.c &

Write a program that uses scanf to get a number from a user and prints “Don’t be so negative!” if they entered a negative number. If the number is positive, the program should print “You have entered a positive number.” If the user enters the number 0, the program should print “You have entered zero.” Your program should behave as follows:

$ dcc -o negative negative.c
$ ./negative
3
You have entered a positive number.
$ ./negative
-3
Don't be so negative!
$ ./negative
0
You have entered zero.

To run some simple automated tests:

$ 1511 autotest negative

To run Styl-o-matic:

$ 1511 stylomatic negative.c
Looks good!

You’ll get advice if you need to make changes to your code.

Submit your work with the give command, like so:

$ give cs1511 wk02_negative

Or, if you are working from home, upload the relevant file(s) to the wk02_negative activity on Give Online.