C - Variables, if, else, while Flashcards
Keywords
auto double int struct
break else long switch
case enum register typedef
char extern return union
const float short unsigned
continue for signed void
default goto sizeof volatile
do if static while
unsigned int
The range specified in the Standard for an unsigned int is 0 to at least 65535, meaning that it cannot be negative.
unsigned int. These variables are supposed to be stored in whatever is the most convenient unit for the machine running your program. The int is the natural choice for undemanding requirements when you just need a simple integral variable, say as a counter in a short loop. There isn’t any guarantee about the number of bits that an int can hold, except that it will always be 16 or more.
The type void
The type specifier void indicates that no value is available.
The void Type
Function returns as void
There are various functions in C which do not return any value or you can say they return void. A function with no return value has the return type as void. For example, void exit (int status);
Function arguments as void
There are various functions in C which do not accept any parameter. A function with no parameter can accept a void. For example, int rand(void);
Pointers to void
A pointer of type void * represents the address of an object, but not its type. For example, a memory allocation function void *malloc( size_t size ); returns a pointer to void which can be casted to any data type.
Printing the integral types
%c char (in character form)
%d decimal signed int, short, char
%u decimal unsigned int, unsigned short, unsigned char
%x hexadecimal int, short, char
%o octal int, short, char
%ld decimal signed long
%lu %lx %lo as above, but for longs
The difference between char and int variables
is that, unless otherwise stated, all ints are signed. The same is not true for chars, which are signed or unsigned depending on the implementor’s choice; the choice is presumably taken on efficiency grounds.
The difference between the two types integral types, signed and unsigned.
Signed types are those that are capable of being negative, the unsigned types cannot be negative at any time. Unsigned types are usually used for one of two reasons: to get an extra bit of precision, or when the concept of being negative is simply not present in the data that is being represented.