K&R C Programs Exercise 7-3

Exercise 7-3. Revise minprintf to handle more of the other facilities of printf. K&R’s minprintf (Section 7.3) handles only %d and %s. The cleanest way to extend it: as we parse the format string, collect the complete format specifier (flags, width, precision, length modifier, conversion character) into a local buffer, then call printf with that …

K&R C Programs Exercise 6-5

Exercise 6-5. Write a function undef that will remove a name and definition from the table maintained by lookup and install. K&R Section 6.6 presents a hash table with separate chaining: an array of HASHSIZE buckets, each being the head of a linked list of struct nlist nodes. install adds a name/definition pair; lookup finds …

K&R C Programs Exercise 6-2

Exercise 6-2. Write a program that reads a C program and prints in alphabetical order each group of variable names that are identical in the first 6 characters, but different somewhere thereafter. Don’t count words within strings and comments. Make 6 a parameter. The strategy: Use the improved getword from Exercise 6-1 to read identifiers, …

K&R C Programs Exercise 6-1

Exercise 6-1. Our version of getword does not properly handle underscores, string constants, comments, or preprocessor control lines. Write a better version. K&R’s getword from Section 6.3 reads the next identifier or non-alphabetic character from input, but has four gaps: Underscores: valid in C identifiers (_var, size_t) but the original checks only isalpha String constants: …

C Program to implement Linear regression algorithm.

Linear Regression  is the predicting the value of one scalar variable(y) using the explanatory another variable(x). Linear regression  is represented by the equation Y = a + bX, where X is the explanatory variable and Y is the scalar variable. The slope of the line is b, and a is the intercept. For linear list …