The Result of program after execution will be displayed as:
A char is 1 bytes
An int is 2 bytes
A short is 2 bytes
A long is 4 bytes
An unsigned char is 1 bytes
An unsigned int is 2 bytes
An unsigned short is 2 bytes
An unsigned long is 4 bytes
A float is 4 bytes
A double is 8 bytes
a = 1023
a = 1777
a = 3ff
b = 2222
c = 123
d = 1234
e = X
f = 3.141590
g = 3.141593
a = 1023
a = 1023
a = 1023
a = 1023
a = 1023
f = 3.141590
f = 3.141590
f = 3.142
f = 3.14159
f = 3.14159 |
Before its use, a variable in a C program, it must be declared. A variable declaration tells the compiler the name and type of a variable and optionally initializes the variable to a specific value.
If your program attempts to use a variable that hasn't been declared, the compiler generates an error message. A variable declaration has the following form:
typename varname;
typename specifies the variable type and must be one of the keywords. varname is the variable name. You can declare multiple variables of the same type on one line by separating the variable names with commas:
int count, number, start; /* three integer variables */
float percent, total; /* two float variables */
The typedef Keyword
The typedef keyword is used to create a new name for an existing data type. In effect, typedef creates a synonym. For example, the statement
typedef int integer;
here we see typedef creates integer as a synonym for int. You then can use integer to define variables of type int, as in this example:
integer count;
So typedef does not create a new data type, it only lets you use a different name for a predefined data type.
|