C - Programming Notes Unit 2
C - Programming Notes Unit 2
1. C program Structure
pre-processor directives
global declarations
main()
{
local variable deceleration
statement sequences
function invoking
}
2. C Keywords
Keywords are the words whose meaning has already been explained to the C
compiler. There are only 32 keywords available in C. The keywords are also called
‘Reserved words’.
\a - Bell
\n - New line
\r - Carriage return
\b - Backspace
\f - Formfeed
\t - Horizontal tab
\" - Quotation mark
\v - Vertical tab
\' - Apostrophe
\\ - Backslash
\? - Question mark
\0 – Null
7. Receiving input values from keyboard
Format string contains placeholders for variables that we intend to receive from
keyboard. A & sign comes before each variable name that comes in variable listing.
Character strings are exceptions from this rule. They will not come with this sign
before them.
Note: You are not allowed to insert any additional characters in format string other
than placeholders and some special characters. Entering even a space or other
undesired character will cause your program to work incorrectly and the results will
be unexpected. So make sure you just insert placeholder characters in scanf format
string. The following example receives multiple variables from keyboard.
float a;
int n;
scanf("%d%f",&n,&a);
Pay attention that scanf function has no error checking capabilities built in it.
Programmer is responsible for validating input data (type, range etc.) and preventing
errors