Welcome to the Builder Academy

Question Programming C Tips.

More
21 Jun 2016 19:15 #6035 by Liko
Programming C Tips. was created by Liko
Hello,
here are some things that may help programmers. Feel free to add your own tips:

C Keywords:

auto: Defines a local variable

break: Passes control out of a the compound statement

case: Used in switch statement to represent the branch point containing the compound statement.

char: Represents the data type that holds characters

const: makes variable value or pointer parameter unmodifiable

continue: Passes control to the beginning of the lop

default: Specifies the default block of code in a switch statement

do: keyword do is usually used together with while to make another form of repeating statement. It starts a do while loop.

double: represents a double precision floating point data type.

else: Indicates an alternative branch in the if else statement

enum: Defines a set constants of type int

extern: Indicates that an identifier is defined elsewhere

float: The keyword float usually represents a single precision floating point data type.

for: Used in for loop to provide iteration facility repeatedly

goto: Used to jump the control unconditionally from one part to another

if: Used to execute the statements conditionally

int: Refers to a fundamental data type that holds integer type values.

long: Modifier used to hold long type values along with basic data.

register: Tells the compiler to store the variable being declared in a CPU register

return: Exits immediately from the currently executing function to the calling routine, optionally returning a value

short: Modifier used to represent the short type values of basic data types

signed: Modifier that holds the signed type values of data type

sizeof: Returns the size of a specified parameter

static: Preserves variable value to survive after its scope ends

struct: Groups variables into a single record

switch: Multiple branching statement which causes control to branch to one of a list of possible statements in the block of statements

tyepdef: Assigns new name to data type definition

union: Groups the variables sharing the same storage space

unsigned: Modifier used to represent the unsigned type values of a data type

void: Represents the empty data type.

volatile: Indicates that a variable can be changed by a background routine

while: Repeats execution of statements while condition is true


Data Types:


char: %c

signed char: %c(%hhi for numerical output) Range: -127, 127

unsigned char: %c(%hhu for numerical output)

short,short int, signed short, signed short int: %hi Range: -32767, 32767

unsigned short, unsigned short int: %hu

int, signed, signed int: %i or %d Range: -32767, 32767

unsigned, unsigned it: %u

long, long int, signed long, signed long int: %li Range: −2147483647, 2147483647

unsigned long, unsigned long int: %lu

long long, long long int, signed long long, signed long long int: %lli Range: −9223372036854775807, 9223372036854775807

unsigned long long, unsigned long long int: %llu

float: %f

double: %f, %F, %g, %G, %e, %E

long double: %Lf, %LF, %Lg, %LG, %Le, %LE


Escape Sequences:

\a - Alert(bell) character

\b - Backspace

\f - Form Feed

\n - Newline

\r - Carriage Return

\t - Horizontal tab

\v - Vertical tab

\\ - Backslash

\' - Single quotation mark

\" - Double quotation mark

\? - Question Mark

\0 - Null character

\ooo - Octal Number

\xhhh - Hexadecimal Number

Randian(0.0.0)
Owner/Developer

Please Log in or Create an account to join the conversation.

More
22 Jun 2016 01:48 #6036 by Liko
Replied by Liko on topic Programming C Tips.
Conversion Specifiers for printf(send_to_char):

%c: To print the character type.

%d: To print the integer type.

%f: To print the floating point type.

%e/%E: To display the floating point with exponent.

%g: To display the floating point data with or without exponent. (Trailing zeroes will not be displayed)

%s: To display a string.

%lf: To display long float or double.

%ld: To display long integer.

%o: To display octal integer.

%x/%X: To display hexadecimal integer.

%i: To display decimal or octal or hexadecimal integer.

%h: To display a short integer.

%u: To display unsigned integer.

Randian(0.0.0)
Owner/Developer
The following user(s) said Thank You: Dvinn

Please Log in or Create an account to join the conversation.

Time to create page: 0.172 seconds