Exercises : Answer the following Question

Submitted by tushar pramanick on Thu, 03/07/2013 - 12:53

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 Questions and Exercises."

    Given an int variable x and an unsigned int variable y, as well as x = 0x8765 and y = 0x8765, is x equal to y?
    Given that the int data type is 16 bits long, what is the hex format of the decimal number -23456?
    Which format specifier, %ld or %lu, should be used to specify an unsigned long int variable?
    What is the name of the header file you have to include if you're calling some C math functions from your C program?

Exercises

Given the following statements,
    int x;
    unsigned int y;
    x = 0xAB78;
    y = 0xAB78;
write a program to display the decimal values of x and y on the screen.
   

Write a program to measure the sizes of short int, long int, and long double on your machine.
   

Give the binary representations of the following:
        512
        -1
        128
        -128

Write a program to display the decimal value given in quiz question 2 in the hex format. Does the result from the program match your answer to that question?


Given an angle of 30 degrees, write a program to calculate its sine and tangent values.
Write a program to calculate the non-negative square root of 0x19A1.

 

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.