$20.99
Exercise #2:
-----------
- Modify the scan.c example from my notes so that it
reads in a double and a long instead of a float and
an int. Also, initialize the two variables so that
they do not contain "junk" at the beginning of the
program.
Exercise #3:
-----------
- Write a program to compute the volume of a cylinder.
Make the result be a floating-point result.
Choose integer or floating-point for the radius and height.
Volume is pi times radius squared times height.
Exercise #4:
-----------
- Write a program that reads in and then displays a person's name.
- Read the first and last name and middle initial and then use
strcpy and strcat to build output strings.
- Display the name as "First Initial. Last"
- And also as "Last, First Initial"
Ex:
Enter first name: John
Enter last name: Doe
Enter middle initial: H
Name: John H. Doe
Name: Doe, John H.
Exercise #5:
-----------
- In a single program write two loops:
- A while loop that prints the multiples of 5, from 100
down to and including 5.
- A second version that is a for loop.
{One program, two loops, no input.}
Exercise #6:
------------
- Modify an example to produce 5 random years
in the current decade (2010-2019.)
Exercise #7:
------------
- Write a program that reads the length and width of a
rectangle, and then computes the area of the rectangle.
Print a label/message that identifies it as the area
of a rectangle, or as the area of a square (if the
length and width are equal.)
{Note: Remember the difference between equality '=='
and assignment '='.
- See what happens if you use '=' instead of
'=='.
- Use -Wall to see that the compiler warns you
when using '=' in a boolean/test context. }
Exercise #8:
-----------
- Modify the example from class to also find
the largest negative and largest positive number
- Modify the example to also find the smallest
negative and smallest positive number
Exercise #9:
------------
Write a short program that reads the Standard Input
until EOF and converts all alphabetic characters to
uppercase.
Notes:
- Don't convert non-alpha characters
- You only need to convert lowercase
Characters
Exercise #10:
------------
Modify the cards2.c program to print the
suit and the face value for each card that is displayed.
Notes:
- The cards2.c already indicates a suit and a
unique value for each card
- Look at Cards3.c and Cards4.c to see the
type of output we are looking for (No face
values are displayed.)
- You should be able to write a little bit
of code of your own for cards2.c to print
like cards3 and cards4, and also print the
face value; without doing exactly what cards3
and cards4 do.
Hint: Use some conditional statements
Exercise #11:
-------------
- Write a function cardValue() that is passed
a single integer parameter representing a
playing card (0-51) and returns the card's
value in the game of BlackJack.
2-10: value is 2-10
Jack/Queen/King: value is 10
Ace: value is 11 or 1
(Ignore 1 for now.)
Exercise #12:
-------------
- Write a recursive function printBinary( )
that displays the binary representation
of an integer. Use recursion.c and
recursion2.c as examples.
Exercise #12:
-------------
- Write a recursive function printBinary( )
that displays the binary representation
of an integer. Use recursion.c and
recursion2.c as examples.
Exercise #15:
------------
- Modify the example sort1.c to store and
sort an array floating-point values. Then
modify it to sort into ascending order.
Generate the values to be sorted using
rand( ).
Notes:
- Do it in careful, minimal steps:
- Steps:
- convert the data to be sorted to
floating-point
- change the sort order to
ascending
- figure out how to generate a
random sequence of floating-point
values using rand()
- Not all data and variables will need to change,
counts and indexes are integers regardless of
the type of data in the array
- If you get stuck, retreat to the original
example and try the part that is causing you
trouble, or just start over.
Exercise #16:
------------
- code a loop that processes a string and converts
all alphabetic characters to upper case.
Exercise #17:
------------
- Make a 2-D array to represent a Tic-Tac-Toe
game/grid. Place a couple of 'X's and 'O's
in the grid and display it.
- Use the mArray1.c - mArray6.c examples in
the Supplement.pdf file as a guide.