K&R C Chapter 4 Exercise Solutions — Functions and Program Structure

Chapter 4: Functions and Program Structure is where K&R builds a non-trivial program: a reverse Polish notation (RPN) calculator. The exercises extend it — adding modulo, unary minus, variables, and last-printed-value recall. Other exercises cover recursive printd, recursive itoa, and the C preprocessor. Exercise 4-12 (recursive itoa) and 4-13 (recursive reverse) are elegance tests. These …

C Program to solve equations using Jordan elimination method.

Write a C Program to solve equations using Jordan elimination method.Gauss-Jordan elimination method is used to solve the linear equations. In this method, We find the inverse matrix of the coefficients of equations by elementary row operations. Read more about C Programming Language . and read the C Programming Language (2nd Edition) by K and …

C Program to lock file using semaphores.

Write a C Program to lock file using semaphores.Using semaphores, We can control access to files, shared memory and other things. The basic functionality of a semaphore is that you can either set it, check it, or wait until it clears then set it (“test-n-set”). In C semaphores functions defined in the sys/sem library. Read …

C program to Encrypt and Decrypt a password

C Strings:Write a C program to Encryption and Decryption of password.In this program we encrypt the given string by subtracting the hex value from it. Password encryption is required for the security reason, You can use so many functions like hash or other keys to encrypt. Read more about C Programming Language . and read …

C Program to solve the producer consumer problem

C Program to Solve the Producer-Consumer Problem Using Semaphores The producer-consumer problem (also called the bounded-buffer problem) is a classic process synchronization problem. A producer process generates data items while a consumer process reads them; a semaphore enforces the ordering so the consumer never reads ahead of the producer. Note: This program uses POSIX System …

C program to implement Round Robin CPU scheduling algorithm.

Write a C program to implement Round Robin CPU scheduling algorithm.In Round Robin scheduling algorithm, a small time slice or quantum is defined, all the tasks are kept in queue. The CPU scheduler picks the first task from the queue ,sets a timer to interrupt after one quantum, and dispatches the process. If the process …