K & R C Chapter 7 Exercise Solutions.

We have already provided solutions to all the exercises in the bookC Programming Language (2nd Edition) popularly known as K & R C book.

In this blog post I will give links to all the exercises from Chapter 7 of the book for easy reference.

Chapter 7: Input and Output

  1. Exercise 7-1. Write a program that converts upper case to lower or lower case to upper, depending on the name it is invoked with, as found in argv[0].
    Solution to Exercise 7-1.
  2. Exercise 7-2.Write a program that will print arbitrary input in a sensible way. As a minimum, it should print non-graphic characters in octal or hexadecimal according to local custom, and break long text lines.
    Solution to Exercise 7-2.
  3. Exercise 7-3.Revise minprintf to handle more of the facilities of printf .
    Solution to Exercise 7-3.
  4. Exercise 7-4. Write a private version of scanf analogous to minprintf from the previous section.
    Solution to Exercise 7-4.
  5. Exercise 7-5. Rewrite the postfix calculator of Chapter 4 to use scanf and/or sscanf to do the input and number conversion.
    Solution to Exercise 7-5.
  6. Exercise 7-6. Write a program to compare two files, printing the first line where they differ.
    Solution to Exercise 7-6.
  7. Exercise 7-7. Modify the pattern finding program of Chapter 5 to take its input from a set of named files or, if no files are named as arguments, from the standard input. Should the file name be printed when a matching line is found?
    Solution to Exercise 7-7.
  8. Exercise 7-8. Write a program to print a set of files, starting each new one on a new page, with a title and a running page count for each file.
    Solution to Exercise 7-8.
  9. Exercise 7-9. Functions like isupper can be implemented to save space or to save time. Explore both possibilities.
    Solution to Exercise 7-9.
You can purchase the book from here or here.

To get regular updates on new C programs, you can Follow @c_program

You can discuss these programs on our Facebook Page. Start a discussion right now,

our page!

Like to get updates right inside your feed reader? Grab our feed!

To browse more C Programs visit this link
(c) www.c-program-example.com

C Aptitude Questions and answers with explanation

C Aptitude 8
C program is one of most popular programming language which is used for core level of coding across the board. C program is used for operating systems, embedded systems, system engineering, word processors,hard ware drivers, etc.

In this site, we have discussed various type of C programs till date and from now on, we will move further by looking at the C aptitude questions.

In the coming days, we will post C aptitude questions, answers and explanation for interview preparations.

The C aptitude questions and answers for those questions along with explanation for the interview related queries.

We hope that this questions and answers series on C program will help students and freshers who are looking for a job, and also programmers who are looking to update their aptitude on C program.
Some of the illustrated examples will be from the various companies, and IT industry experts.
Read more about C Programming Language . and read the C Programming Language (2nd Edition). by K and R.

Predict the output or error(s) for the following:

C aptitude 8.1

  main()
{
char *p="hai friends",*p1;
p1=p;
while(*p!='