Add exercise (2-6)
Exercise 2-6:
Write a function setbits(x,p,n,y) that returns x with the n bits that
begin at position p set to the rightmost n bits of y, leaving the other
bits unchanged.
Add exercise (2-7)
Exercise 2-7:
Write a function invert(x, p, n) that returns x with the n bits that
begin at position p inverted (i.e., 1 changed into 0 and vice versa),
leaving the others unchanged.
Add exercise (2-5)
Exercise 2-5:
Write the function any(s1 ,s2), which returns the first location in the
string s1 where any character from the string s2 occurs, or -1 if s1
contains no characters from s2. (The standard library function strpbrk
does the same job but returns a pointer to the location.)
Ignore notes I've been taking
Add exercise (2-4)
Exercise 2-4:
Write an alternate version of squeeze(s1 ,s2) that deletes each
character in s1 that matches any character in the string s2.
Add exercise (2-3)
Exercise 2-3:
Write the function htoi(s), which converts a string of hexadecimal
digits (including an optional Ox or Ox) into its equivalent integer
value. The allowable digits are 0 through 9, a through f, and A through
F.
Specify signed or unsigned char for portability
Add exercise (2-2)
Exercise 2-2:
Write a loop equivalent to the for loop above without using && or ||.
Add exercise (2-1)
Exercise 2-1:
Write a program to determine the ranges of char, short, int, and long
variables, both signed and unsigned, by printing appropriate values from
standard headers and by direct computation. Harder if you compute them:
determine the ranges of the various floating-point types.
Add exercise (1-22)
Exercise 1-22:
Write a program to "fold" long input lines into two or more shorter
lines after the last non-blank character that occurs before the n-th
column of input. Make sure your program does something intelligent with
very long lines, and if there are no blanks or tabs before the specified
column.
Add exercise (1-23)
Exercise 1-23:
Write a program to remove all comments from a C program. Don't forget to
handle quoted strings and character constants properly. C comments do
not nest.
Add programs to experiment with EOF character
Add exercise (1-21)
Exercise 1-21:
Write a program entab that replaces strings of blanks by the minimum
number of tabs and blanks to achieve the same spacing. Use the same tab
stops as for detab. When either a tab or a single blank would suffice to
reach a tab stop, which should be given preference?
Add exercise (1-20)
Exercise 1-20:
Write a program detab that replaces tabs in the input with the proper
number of blanks to space to the next tab stop. Assume a fixed set of
tab stops, say every n columns. Should n be a variable or a symbolic
parameter?
Add exercise (1-19)
Exercise 1-19:
Write a function reverse(s) that reverses the character string s. Use it
to write a program that reverses its input a line at a time.
Add exercise (1-18)
Exercise 1-18:
Write a program to remove trailing blanks and tabs from each line of
input, and to delete entirely blank lines.
Add exercise (1-17)
Exercise 1-17:
Write a program to print all input lines that are longer than 80
characters.
Add exercise (1-16)
Exercise 1-16:
Revise the main routine of the longest-line program so it will correctly
print the length of arbitrarily long input lines, and as much as
possible of the text.
Add exercise (1-15)
Exercise 1-15:
Rewrite the temperature conversion program of Section 1.2 to use a
function for conversion.