C - Variables, if, else, while Flashcards

1
Q

Keywords

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

unsigned int

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The type void

A

The type specifier void indicates that no value is available.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

The void Type

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Printing the integral types

A

%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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

The difference between char and int variables

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

The difference between the two types integral types, signed and unsigned.

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly