Programming Project 1:
largest and smallest
- Write a program that reads an integer value n, then it reads in n integer values. Then it outputs the largest and the smallest of the n integer values.
- Example (in red the program outputs and in black the user inputs):
- How many numbers?
- 10
- Give me the 10 numbers
- 7, 21, 5, 12, 14, 2, 1, 34, 9, 6
- Smallest number is 1
- Largest number is 34
- Use either a for or a while loop.
Programming Project 2:
Hexadecimal numbers
- A Hexadecimal number is a number written in base 16 using as sixteen digits, 0 to 9 for the first 10, and A for 10, B for 11, C for 12, D for 13, E for 14, F for 15.
- For instance
- AB3=10×162+11×16+3×160=2739
- CAFE=12×163+10×162+15×161+14×160=51966
- Write a program that takes as input a number base 10 (example 51966) and it outputs the corresponding hexadecimal number (CAFE).
Programming Project 3:
Reversing a number
- Write a program that reads an integer value n, and then reverses its digits.
- Example (in red the program outputs and in black the user inputs):
- Give me the number
- 375
- Here's the number in reverse
- 573
- Use either a for or a while loop. Do not use arrays (you don't know what they are yet!) to hold the digits.
- Just note that, for example, to reverse 31, first you get 1, then you get 3 (second digit) and you add it to the first digit multiplied by 10, obtaining 3+1×10=13.
- To reverse 231, reverse the first 2 digits (as above) and then add the last digit 2, to the number obtained reversing the first 2 digits multiplied by 10, obtaining 2+13×10=132