Saturday, 24 August 2013

C Basic Concepts



  1. We cannot apply indirection operator to void pointer. (101)

  2. Check question 33,47,49,54,67,79,85,90,94,99,101,104,106, 112, 117, 121,152,160,174,51 again

  3. We cannot apply bitwise shift operator or mod operation to float variables

  4. If the structure is globally declared all the variables are initialized to zero.

  5. When passing array to function, function parameter is implemented as pointer only(94)

  6. Function name preceded by 'pascal' keyword refers to pascal passing mechanism (left to right) while in 'cdecl' variables are passed from right to left (111)


  7. int* arr[8]; // An array of int pointers.
    int (*arr)[8]; // A pointer to an array of integers (http://stackoverflow.com/questions/859634/c-pointer-to-array-array-of-pointers-disambiguation)


  8. Macros can be re-define anywhere in the program

  9. In C, Unary + is a dummy operator.

  10. Enumeration constants cannot be modified(113)

  11. We cannot create a variable of type void.

  12. If a name is not known pre-processor treats it as equal to zero (119)

  13. & ( Address of ) Operator is not applicable for register variable (139)

  14. Small-endian ( Lower order bytes are stored in higher memory address and Higher order bytes are stored in Lower memory address). Eg:  300 Binary Representation is - 00000001 00101100. In memory it is stored as 00101100 00000001.

  15. Forward declaration is not allowed in c (154,155)

  16. The values of any type tend to rotate after a particular value Eg; for 'char' after 127  it moves to -128.

  17. Character constants are stored in code/data area. They are not stored in stack. So there might not be dangling pointer issue

  18. Initializing  structure variable inside structure is not allowed

  19. Arrays are non-modifiable Lvalue

  20. When two strings are placed together they are concatenated,this is know as stringization

  21. Empty object size is always one.

  22. Function overloading cannot be resolved based on return type alone.

  23. Expression will not be evaluated inside the sizeof operator

  24. http://stackoverflow.com/questions/501816/why-does-cout-print-char-arrays-differently-from-other-arrays

  25. http://www.geeksforgeeks.org/storage-for-strings-in-c/

  26. http://www.geeksforgeeks.org/swap-strings-in-c/

  27. In C, when we initialize less no of elements in an array all uninitialized elements become ‘′ in case of char and 0 in case of integers. ( http://geeksquiz.com/string/ Question 8 )

  28. In C, struct and union types cannot have static members.

  29. http://geeksquiz.com/structure-union/ (last Question )

  30. http://geeksquiz.com/dynamic-memory-allocation/ (Third Question)

  31. In C, static variables can only be initialized using constant literals. This is allowed in C++ though (http://www.geeksforgeeks.org/g-fact-80/)

  32. http://www.geeksforgeeks.org/are-array-members-deeply-copied/

  33. In C and C++ arguments are passed by value by default

  34. http://www.learncpp.com/cpp-tutorial/123-virtual-destructors-virtual-assignment-and-overriding-virtualization/


Constant Object



  1. The member variables cannot be changed.

  2. It can access only constant member functions and constant member variable int that class.


Constant Member Function



  1. The state of the object cannot be changed inside the constant member function

  2. Variable declared as mutable can be changed.


Static variables



  1. Created and initialized only once.

  2. Shared among all members.


Static Functions



  1. Can access only static members of the class

  2. Cannot access other members.

  3. Can be called without using objects and can be called using objects also

No comments:

Post a Comment