Professional Documents
Culture Documents
standards
27 keywords - used in language - ANSI - +5 keyword added
C89 - 32 keywords
C91
C95
C99 - + 5 keywords = 37 keyword
C11
for laptop
start --> run -->\\sunbeama\precatassign
username:precat
password:precat
for desktop
smb://172.0.1.210/precatassign
Definition
function definition actual set of instructions collected together to
complete task--sub program
types Errors:
1. Complie-time errors
2. runtime time
3. logical errors
4. linker error
formatted function
printf,scanf,fprintf,fscanf
unformatted function
getchar,gets,puts,getc etc.
Format specifiers
%c converts data into character
%d converts data into signed int
%f converts data into float(6 precisions)
%s converts data into string
%ld converts data into long int
%u converts data into unsigned format
%x converts data into hexadecimal format
%o converts data into octal format
%e converts data into exponetial format
Rules of Identifier
1. should start with alphabet or with _ (underscore)
2. can include alphabets,_ (underscore),digits
cvar_1 //valid
1_cvar //not valid
_cvar1 //allowed
cvar-1 //not allowed
Type Modifiers:
1. signed --char -128 to 127
2. unsigned ---char 0 to 255
3. short
4. long
three streams
1. stdin - standard input stream
2. stdout - standard output stream
3. stderr
Arithmetical Operators + - / * %
Relational Operators > < >= <= != ==
Logical Operators && || !
Bitwise Operators & | ^ ~ << >>
Assignment Operator =
Unary Operators + - ++ -- * & . ->
Ternnary/conditional Operators ? :
shorthand operators += -= /= *= %=
&= |= ^= ~= <<= >>=
special operators sizeof , (comma)
Decision Control:
if(<expression>)
{
<true block statements>
}
if(<expression>)
{
<true block statements>
}
else
{
<false block statements>
}
if(<expression>)
{
if(<expression>)
{
<true block statements>
}
}
else
{
<false block statements>
}
if(<expression>)
{
<true block statements>
}
else if(<expression>)
{
<true block statements>
}
else if(<expression>)
{
<true block statements>
}
else
{
<true block statements>
}
Conditional Operator
? :
switch(<expression>)
{
case <integer constant>:
<statements>
break;
case <integer constant>:
<statements>
break;
case <integer constant>:
<statements>
break;
default:
<statements>
break;
}
1. It is necessary that case has to be followed by integer constant.
2. every case last statement has to be break statement.
break: is a jump statement which can be used in switch / loop.
break statements helps to move execution control forcefully outof switch / loop
if break statement is not mentioned execution control is given to next cases even
though they are not satisfied. Next cases will be executed till last statment or
till next break statement.
return is jump statement can be used inside function. which helps to move execution
control forcefully back to calling area
If no field is assigned very first member/field of enum recevies default value zero
and next sequential members will receive step 1 value ahead of previous one
typedef is used to give another name to existing data type. Helps to improve
readabilty of source code.
int val;
MARKS m1;
BOOL status;
Category:
1. on entry check loop ----- while , for
2. on exit check loop ----- do while
Conventionally it is said that if no. of iterations are fixed in advance then use
counter loop i.e. for loop
Conventionally it is said that if no. of iterations are not known in advance then
use while or do while loop.
jump statements:
break - can be used inside switch or loop which helps to move execution control
forcefully outof loop/switch
return - can be used inside function helps to move execution control forcefully
back to calling function
continue: can be used only inside loop. Helps to move execution control forcefully
to next iteration. Whenever continue is encountered all c statements below continue
are skipped from evaluation in current iteration from.
goto: can be used to mark statements as label and jump to specific label definition
with goto we can jump to label definition which is in scope of current function.
<LABEL>:
<statements>
goto <LABEL>;
do
{
<statements>
}while(<expression>); //on exit check loop
i=5; i=5;
while(i>=10) do
{ {
printf("\n Inside"); printf("\n Inside");
} }while(i>=10);
for loop:
Types of functions:
1. Library Functions
2. user defined functions
Calling Conventions:
_CDecl
_stdCall
pascal
_fastcall
a++ + ++b
a=11 b=3
printf("\n %d %d %d",++a,b++,a=10);
11 2 10
a=2;
printf("\n %d %d %d",++a,a++,++a);
}
<return type> <identifier> ([<arg type> <identifier>...])
{
}
3. call
int x= printf("Hello World");
<location> = <identifier>(<arg value/address>);
Storage Classes:
scope life memory from default value
auto block block stack garbage
As no. of registers availability is very less our request may be rejected and it
will be automatically converted in auto type. Needs more time and slows down
performance
static:
1. can be declared within function
2. it is neceesary to initialise static variables at the time of
declaration else it voilets the rule of static
3. static variable is to be initialised with constant value only.
recursion loop
uses more memory less memory utilisation
Pointer: is a derived data type. Using pointer concept we can create a variable to
store address. We hould always store a valid/in alive state address in pointer.
Address through system is always given in unsigned int format. Hence size of any
pointer will be equals to unsigned int of respective compiler.
void pointer is not aware of scale factor i.e. how many bytes to be dereferred from
given base address. Hence if we want to receive value at void pointer it is
necessary always typecast prior its to use.
void *vptr;
vptr=&x;
*vptr ?????????? // error unknown abot bytes to be derefferred
In case array a common name is shared amongst all members where as every member is
uniquely identified with index value.
Very first element of array receives by default index as 0 and last (nth position)
element receives index as n-1
When we request array a location is identified with array name stores always first
element address of first element because of which array interchangability with
pointer is possible