Saturday, October 8, 2016

C Syllabus




Overview of C Language
·         Where is it used
·         Your First Program
·         Role of Compiler
·         Role of Interpreter
·         Data Type
·         How to declare Variables
·         ASCII Code Table
·         Type Casting
·         Operators in C/C++
·         Life Cycle of Integer
·         Conditional Statement
·         If else
·         Ternary operator
·         Switch case
·         Loops

·         Loop Types
·         (for,while,do while)
·         Array

·         Array Types
·         Single Dimensional array
·         Double Dimensional array
·         Single Character Array
·         String
·         Function
·         Pointer
·         Understanding Pointers
·         Pointer expressions
·         Pointer and Arrays
·         Pointers and Character String
·         Pointers to Functions
·         Pointers and Structures Call By
·         Reference Function
·         Structure
·         File Management In C
·         Introduction to File Management
·         Opening/Closing a File
·         Input/Output operations on Files
·         Error Handling During I/O Operations
·         Command Line Arguments
·         Structures And Unions
·         Defining a Structure
·         Advantage of Structure
·         Dynamic Memory Allocation
·         Introduction to Dynamic Memory Allocation
·         Malloc
·         Calloc
·         Realloc
·         Free
·         Preprocessor
·         39.Macro Substitution
·         File Inclusion
·         Computer Control Directives





·         C/C++ Interview Questions and answer 

1.What is a class?

      Class is a blue print which reflects the entities attributes and actions. Technically defining a class is designing an user defined data type.

2.What is an object?

      An instance of the class is called as object.

3.List the types of inheritance supported in C++.

     Single, Multilevel, Multiple, Hierarchical and Hybrid.

4.What is the role of protected access specifier?

     If a class member is protected then it is accessible in the inherited class. However, outside the both the private and protected members are not accessible.

5.What is encapsulation?

      The process of binding the data and the functions acting on the data together in an entity (class) called as encapsulation.

6.What is abstraction?

      Abstraction refers to hiding the internal implementation and exhibiting only the necessary details.

7.What is inheritance?

      Inheritance is the process of acquiring the properties of the existing class into the new class. The existing class is called as base/parent class and the inherited class is called as derived/child class.

8.Explain the purpose of the keyword volatile.         

     Declaring a variable volatile directs the compiler that the variable can be changed externally. Hence avoiding compiler optimization on the variable reference.

9.What is an inline function?

      A function prefixed with the keyword inline before the function definition is called as inline function. The inline functions are faster in execution when compared to normal functions as the compiler treats inline functions as macros.

10.What is a storage class?

       Storage class specifies the life or scope of symbols such as variable or functions.
    1void function1(){
      int x=20;//local variable
        }

z    12.What is the use of static variable in C?

     int x=10;//local variable
     static int y=10;//static variable
      x=x+1;
      y=y+1;
   printf("%d\n",x);//will always print 11
   printf("%d\n",y);//will always increment value, it will print 11, 12, 13 and so on
   }

     13. What is the use of function in C?

     A function in C language provides modularity. It can be called many times. It saves code and we can reuse the same code many times. More details...

We can pass value to function by one of the two ways: call by value or call by reference. In case of call by value, a copy of value is passed to the function, so original value is not modified. But in case of call by reference, an address of value of passed to the function, so original value is modified. More details...

      Calling the same function, inside function is known as recursion. For example:

function1();//calling same function

      }  
    
     16.Explain abstraction.
      - Simplified view of an object in user’s language is called abstraction. 
     - It is the simplest, well-defined interface to an object in OO and C++ that provides all the expected features and services to the user in a safe and
      predictable manner. 
    - It provides all the information that the user requires.
    - Good domain knowledge is important for effective abstraction. 
     - It separates specifications from implementation & keeps the code simpler and more stable.
     
     17.What is the real purpose of class – to export data?

       No, the real purpose of a class is not to export data. Rather, it is to provide services. Class provides a way to abstract behaviour rather than just 

       encapsulating the bits.
    18.What things would you remember while making an interface?

     - A class’s interface should be sensible enough. It should behave the way user expects it to.   

    -It should be designed from the outside in.

   19.Explain the benefits of proper inheritance.


    The biggest benefits of proper inheritance are : 

          1.Substitutability 
          2.Extensibility. 

   1.Substitutability : 

      The objects of a properly derived class can be easily and safely substituted for an object of its base class. 

   2.Extensibility : 

       The properly derived class can be freely and safely used in place of its base class even if the properly  derived class is created a lot later than defining 
       the user code. Extending the functionalities of a system is much easier when you add a properly derived class containing enhanced functionalities.

   20.How should runtime errors be handled in C++?


 - The run time errors in C++ can be handled using exceptions. 

    - This exception handling mechanism in C++ is developed to handle the errors in software made up of independently developed components operating in one process and under synchronous control. 
    - According to C++, any routine that does not ful fil its promise throws an exception. 
    The caller who knows the way to handle these exceptions can catch it.