C For Dummies

The C programming language is fast and versatile. You can use just 32 keywords and some fairly intuitive symbols to do comparisons and conversions. Then you get to numeric data and math symbols, which are pretty much as you expect as well.






>


>


C Language Comparison Symbols


If you’re writing programs in C, you need to use comparison symbols. The symbols C uses, their meanings, and examples are shown in the following table:






































SymbolMeaning or Pronunciation“True” Comparison Examples
<Less than1 < 5

8 < 9
==Equal to5 == 5

0 == 0
>Greater than8 > 5

10 > 0
<=Less than or equal to4 <= 5

8 <= 8
>=Greater than or equal to9 >= 5

2 >= 2
!=Not equal to1 != 0

4 != 3.99




>



>


>


C Language Comparisons and Their Opposites


If you’re programming in C — or any other language — you need to use If/Else statements. The comparison symbols you need if you’re working with C and the Else statements they generate are shown in the following table:































If ComparisonElse Statement Executed By This Condition
<>= (Greater than or equal to)
==!= (Not equal to)
><= (Less than or equal to)
<=> (Greater than)
>=< (Less than)
!=== (Equal to)




>



>


>


C Language Conversion Characters


When programming in C, you use conversion characters — the percent sign and a letter, for the most part — as placeholders for variables you want to display. The following table shows the conversion characters and what they display:



















































Conversion CharacterDisplays Argument (Variable’s Contents) As
%cSingle character
%dSigned decimal integer (int)
%eSigned floating-point value in E notation
%fSigned floating-point value (float)
%gSigned value in %e or %f format, whichever is shorter
%iSigned decimal integer (int)
%oUnsigned octal (base 8) integer (int)
%sString of text
%uUnsigned decimal integer (int)
%xUnsigned hexadecimal (base 16) integer (int)
%%(percent character)




>



>


>


C Language Escape Sequences


Programming in C is fast — all you have to do is type a short sequence of keystrokes — generally just two — to get a tab, a new line, a question mark, and more. The following table shows the sequences you need to accomplish a variety of tasks:































































SequenceRepresents
\aThe speaker beeping
\bBackspace (move the cursor back, no erase)
\fForm feed (eject printer page; ankh character on the
screen)
\nNewline, like pressing the Enter key
\rCarriage return (moves the cursor to the beginning of the
line)
\tTab
\vVertical tab (moves the cursor down a line)
\\The backslash character
\’The apostrophe
\”The double-quote character
\?The question mark
\0The “null” byte (backslash-zero)
\xnnnA character value in hexadecimal (base 16)
\XnnnA character value in hexadecimal (base 16)




>



>


>


C Language Keywords


The C programming language has just 32 keywords for you to build robust programs. With only 32 keywords, they all fit nicely into a short table. Use them wisely and well.



















































autodoubleintstruct
breakelselongswitch
caseenumregistertypedef
charexternreturnunion
constfloatshortunsigned
continueforstaticvoid
defaultgotosizeofvolatile
doifsignedWhile




>



>


>


C Language Numeric Data Types


When programming with C, keywords and variables go together like the 4th of July and fireworks, although with a bit less drama. The following table shows C keywords, their variable types, and their ranges:


image0.jpg



>



>


>


C Language Mathematical Symbols


Programming math functions with C is fairly straightforward: a plus sign works like any sixth-grader knows it should and does addition. The mathematical symbols and the function they serve in C are shown in the following table:


image0.jpg



>






>
dummies


Source:http://www.dummies.com/how-to/content/c-for-dummies-cheat-sheet0.html

No comments:

Post a Comment