Solution for Exercise 6-2

ex0602

#include <stdio.h>

int main()
{
    char c;
    int i;
    float f;
    double d;

    c = 'a';
    i = 1;
    f = 19.0;
    d = 20000.009;

    printf("%c\n",c);
    printf("%d\n",i);
    printf("%f\n",f);
    printf("%f\n",d);
    return(0);
}

Notes

* Remember to specify single characters by placing them in single quotes, such as 'a'.

* To specify the single quote character, you use the \' escape sequence, as in '\''.

* Characters you can't type are specified by their ASCII code. Place the character's hexadecimal code value into single quotes by using the \x escape sequence. So to reference the character code 11, which is hexadecimal 0B, you would use '\x0B'