Skip to content

Commit 220812e

Browse files
authored
Update README.md
1 parent aa660c9 commit 220812e

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,23 @@
1-
# Assignment2
1+
# Assignment 2
22

33
## Objectives
44

55
To gain a solid understanding of Operators, System Input/Output, Conditional Statements, and Relational and Boolean Operators.
66

77
### Part 1
88

9-
1. Write a program to check if a number is positive or negative.
9+
1. Write a program to check if a user-input number is positive or negative. Assume the user enters a valid number, but that number may not be an integer. File name is your choice, as long as it makes sense.
1010

11-
2.
11+
2. Write a calculator program `calculator.c` that prompts the user with a menu for operations (+, -, *, /, %), takes in 2 numbers, and performs the selected operation. The menu selection should be interpreted using a switch statement. You may assume the user will enter any 2 valid numbers.
12+
13+
3. Write a random number guesser `randnum.c` that generates a random integer between 1 and 10 (inclusive), prompts the user for a guess, and tells the user if they guessed correctly, too high, or too low. You may assume the user enters a valid integer. The code below will generate a random integer. Note: You will need to include the stdlib.h and time.h header files.
14+
```c
15+
srand(time(0));
16+
`int r = rand();
17+
```
1218
1319
### Part 2
20+
In a text file `assignment2.txt`, answer the following questions:
1421
1522
1. Can two or more operators be combined in a single line of program code?
1623
@@ -21,6 +28,18 @@ To gain a solid understanding of Operators, System Input/Output, Conditional Sta
2128
x >= 10 && x < 25 && x != 12
2229
```
2330
24-
4.
31+
4. Is the following expression valid? Why or why not?
32+
```
33+
0 < x < 15
34+
```
35+
5. Which of the following are valid? What is wrong with any that are invalid?
36+
1. if (a > b) then c = 0;
37+
2. if a > b { c = 0; }
38+
3. if (a > b) c = 0;
39+
4. if (a > b) c = 0 else b = 0;
40+
41+
### Submission Guidelines
42+
Please include your name and a description in a comment at the top of your code files. Please also include your name at the top of your assignment1.txt file.
2543
44+
All files must be submitted via GitHub by 10:00am 6/30.
2645

0 commit comments

Comments
 (0)