23. C-Important Points

C-Accessing Random File: Previous                                  Next: C-Interview Questions
  • Whenever C program is executed, main( ) is executed. No main( ) means no execution.
  • In conditional if else branching if we have a single statement to write after  if or else then braces are not needed.
E.g.:
o   if(number % 2 == 0)
  • printf(“Number is Even”);
o   else
  • printf(“Number is Odd”);
  • It is convention to write brackets of blocks in a sequence, so that it looks good and errors can be easily traced.
  • With a single ‘if’ block we can have multiple else block, but only one will get executed.
  • In if else if ladder, all relational operators are allowed.
  • Variables take a memory in scattered form.
  • If the conventions of the identifiers are not followed then it will generate an Error.
  • %i can also be used at place of %d.
  • Numbers that have decimal portions are called Real numbers.
  • All statements of a program should be written in lower case.
  • At the place of void main( ), we can write main( ) only but the “return 0” statement is compulsory to be written at the end of all statement but before curly braces.
  • main( ) is a user defined function.
  • To find out name of header file of a pre defined function hen place the cursor under function name and press Ctrl+f1.
  • By default the return data type of main( ) is ‘int’.
  • By default all variables are initialized with some garbage value.
  • Unsigned int can only store positive value.
  • If loop does not contain any statements in its body then it is said to Empty loop.
  • Multiple increment/decrement expression in for loop can be separated by comma.
  • Multiple break statements can be used in a single block of loop.
  • while(1) is used for infinite loop.
  • break is premature loop termination.
  • exit( ) function forces exit from a program.
  • char  data type can take symbol as input.
  • All characters are represented internally as integer in c programming.
  • Nesting of while loop can be done up to 3 levels.
  • The increment/decrement in loops can be written as i = i + 1 as i++;
  • Address of first byte us often known as base address.
  • Address of any variable is always unsigned and range from 0 to 65535.
  • Basically pointer does not have its own data type. But unsigned int can be sat its data type.
  • Arithmetic operation on pointer is called Scaling.
  • Dereferencing operator is unary operator.
  • Nesting of pointer can be till infinity.
  • Comparison of pointer variables can also be performed but they must point to same object.
  • Pointers are mainly used for dynamic memory allocation and it reduces the length and complexity of a program.
Important Points in Pointers:
  • a[i] as same as *(a+i).
  • a[0]+I same as (*a)+i.
  • int (*p)[10] is array of pointer variable p and store s 10 elements in array.
  • Pointer is not integer, so multiplication with another pointer is not allowed.
  • putchar() is used to display a single character on  console.
  • Drawback of array that array can’t b e resized.
  • The difference between arr[5] and arr[5]=10 is first an array name with size and second is particular element means at 5th index awe are assigning element 10 to array.
  • In definition of array, [ ] brackets are only used, ( ) brackets are error not allowed in  C.
  • “M” is string but ‘m ‘ is a character.
  • When char variable written with “%d” then  it will display ASCII value of that particular character.
  • Char charcter[][3]={{‘m’,’a’,’n’},{‘I’,’a’,’f’}}; is valid syntax.
  • Union can be a member of an structure.
  • ‘ -> ‘ operator is used to access member of structure that is itself a member of another structure.
  • Structure always pass to function by call by value mechanism.
  • No limit of nesting of structure are defined in C language programming.
  • ptr is pointer variable to structure then ptr->ptr is same as (*ptr).
C-Accessing Random File: Previous                                  Next: C-Interview Questions