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

Question and Answer

Q Why do characters have their unique numeric values?
Ans Characters are stored in computers in the form of bits. The combinations of bits can be used to represent different numeric values. A character has to have a unique numeric value in order to distinguish itself. Many computer systems support the ASCII character set, which contains a set of unique numeric values for up to 256 characters.

 

Q How can you declare two character variables?
Ans There are two ways to do the declaration. The first one is

           …char variable-name1, variable-name2;
      char  variable-name1;
           char  variable-name2;

 

Q What are %c, %d, and %f?
Ans  These are format specifiers. %c is used to obtain the character format; %d is for the integer format; %f is for the floating-point format. %c, %d, and %f are often used with C functions such as printf().

 

Q What are the main differences between the int data type (integer) and the float data type (floating-point)?

  Ans First, an integer does not contain any fraction parts, but a floating-point number does. A floating-point number must have a decimal point. In C, the float data type takes more bits than the int data type. In other words, the float data type has a larger range of numeric values than the int data type. Also, the integer division truncates the fraction part. For instance, the integer division of 16/10 produces a result of 1, not 1.6.

 

Related Items

The while Loop

The while Loop

The while statement is also used for looping. Unlike the situation with the for statement, there is only one expression field in the while statement.

The general form of the while statement is

while (expression) {

Question and Answer

Question and Answer

    Q How does a for loop work?

Exercises : Answer the following Question

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

 

Working with the Cast Operator

Playing with the Cast Operator

In C, you can convert one data type to a different one by prefixing the cast operator to the operand.

The general form of the cast operator is

(data-type)x

Question and Answer

Question and Answer

    Q What is the difference between the pre-increment operator and the post-increment operator?