Submitted by Anonymous (not verified) on Mon, 02/25/2013 - 23:48

Workshop
To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson. The answers and hints to the questions and exercises are given in Appendix E, "Answers to Quiz Questions and Exercises."

 

Quiz

  1. Can you align your output at the left edge, rather than the right edge, of the output field?
  2. What is the difference between putc() and putchar()?
  3. What does getchar() return?
  4. Within %10.3f, which part is the minimum field width specifier, and which one is the precision specifier?

 

Exercises

  1. Write a program to put the characters B, y, and e together on the screen.
  2. Display the two numbers 123 and 123.456 and align them at the left edge of the field.
  3. Given three integers–15, 150, and 1500–write a program that prints the integers on the screen in the hex format.
  4. Write a program that uses getchar() and putchar() to read in a character entered by the user and write the character to the screen.
  5. If you compile the following C program, what warning or error messages will you get?


    main()
    {
       int ch;
       ch = getchar();
       putchar(ch);
       return 0;
    }

 

Related Items

মডুলার C প্রোগ্রামিং (Modular C Programming)

কেবল মাত্র একটি ফাংশন দিয়ে কোনো বড়ো জটিল সমস্যা সমাধানের চেষ্টা করা ভাল প্রোগ্রামিংয়ের পদ্ধতি নয়। সঠিক পদ্ধতি হ'ল সমস্যাটিকে কয়েকটি ছোট ছোট এবং সরল টুকরো করে ফেলা যাতে তা আরও বিশদে বোঝা যায় । তারপরে এই ছোট এবং সরল সমস্যাগুলি সমাধান করার জন্য ছোট ছোট ফাংশন ব্লক তৈরি করা এবং পরে সেগুলি নিয়মানুযায়ী সংযোজিত করা ।

Programming Style

Programming Style

In this section, I'd like to briefly highlight some points that will help you write clean programs that can easily be read, understood, and maintained.

Exercises : Answer the following Question

To help solidify your understanding of this hour's lesson, you are encouraged to answer the quiz questions and finish the exercises provided in the Workshop before you move to the next lesson.

Question and Answer

    Q Is the C preprocessor part of the C compiler?

    A No. The C preprocessor is not part of the C compiler. With its own line-oriented grammar and syntax, the C preprocessor runs before the compiler in order to handle named constants, macros, and inclusion of files.

Compiling Your Code Under Conditions

Compiling Your Code Under Conditions

You can select portions of your C program that you want to compile by using a set of preprocessor directives. This is useful, especially when you're testing a piece of new code or debugging a portion of code.