Sei sulla pagina 1di 10

C Interview Questions part -1

1. What are the languages from which C was evolved?


ALGOL, BCPL (Basic Combined Programming Language) & B.

2. Who has developed C? When & where has it been developed?


C has been developed by Dennis Ritchie at Bell Laboratories in 1972.

3. What is the other name for C?


K&R C (Kerningham & Ritchie)

4. What is C89?
The version of C which is approved by ANSI (American National Standards Institute) in December 1989 & then
approved by International Standards Organization) in 1990 is known as C89.

5. What is C99?
The 1999 version of C which has got few features of C++ & Java is called C99.

6. What are C99 features?


New Keywords: bool, complex, imaginary, inline, restrict
New comment: Single line comment (//)
New Data Types: Bool, Complex, Imaginary
Declaration of Variables: variables can be declared at any point just before its use unlike C
Changes to I/O formats: ll (long long) format to scanf () & printf ()
Handling of Arrays: Variables length arrays, type specification in array declaration, flexible arrays in structures
Functions implementation: Default to Int rule, Explicit function declaration, Restriction on return statement, inline
functions
Restricted pointers
Changes to compiler limitations

7. What are restricted pointers in C99?


A pointer qualified with restrict is called as restricted pointer. A pointer declared “restricted” is the only way through
which we access the object it points to.
Ex.: int *restrict a;

8. What are variable length arrays in C99?


Variable length arrays are the one in which size of array can be integer variable or any valid integer expression & the
value of which can be specified just before it is used.

9. What are the features of C?


C is a robust, high level, structured programming language which is highly portable, efficient and fast, and has the
ability to extend itself.

10. How do you explain that C is highly portable?


The feature that a C program written for one computer can be run on another computer with little or no modifications
makes it highly portable.

11. Where does the program execution begin in C?


Program execution begins at main () in C.

12. How many main () functions can be used in C?


One.

13. How do use comments in C?


/*….*/ are the comments used in C. Anything enclosed between them are considered as comment lines.

14. Can you nest the comments in C?


No.

15. What comments are used for?


· Documentation of variables and their usage
· Explaining difficult sections of code
· Describes the program, author, date, modification changes, revisions etc
· Copyrighting.

16. What is the statement terminator in C?


Semicolon (;).

17. Is the C language case sensitive or not?


C language is case sensitive & the programs are written in lower case.

18. What do you mean by predefined?


The function that has already been written, compiled, and linked together with a program at the time of linking is called
predefined.

19. What does the keyword “void” indicate?


Void indicates that the function does not return any value.

20. Explain the structure of a C program?


Documentation section, Link section, Definition section, Global Declaration section, main (), subprogram section. Except the
main (), all the other sections are optional.

21. How do you execute a C program in MS-DOS?


There are 3 steps involved in executing a C program: Compiling, Linking and executing.

Compiling is done by the command MSC


which creates an object file called
. Linking is done by the command LINK
which creates a file
. To execute it enter
and the results are displayed.
Basics:

22. What do you mean by trigraph sequences?


Trigraph sequences help us to enter certain characters that are not available on some keyboards.
Ex.:??/ --- represents ^ (caret)
Each sequence consists of 3 characters, 2 question marks followed by 1 character.

23. What are tokens in C?


Smallest individual units are called tokens.

24. What are the types of tokens in C?


Keywords, Identifiers, Constants, Strings, Special symbols, Operators.
25. What do you mean keyword?
Keyword has a fixed meaning which cannot be changed.

26. How many keywords are there in C?


Thirty two (32).

27. What is single character constant?


A single character enclosed within a pair of single quotes is called single character constant.
Ex.: ‘A’

28. What is string constant?


Sequence of characters enclosed in double quotes.

29. What are escape sequences?


The combination of backslash(\) and some character which together represent one character are called escape sequences.
Ex.: ‘\n’ represents newline character.

30. What do you mean by initialization of variable?


Initialization is the process of assigning a value to variable at the time of declaration.

Data Structures Interview Questions Part -1


1. What is an algorithm?
The process of providing solution to a problem is a sequence of steps is called an algorithm.

2. What are the properties of an algorithm?An algorithm must possess the following properties:
a. It should get input data.
b. It should produce output.
c. The algorithm should terminate.
d. Algorithm should be clear to understand.
e. It should be easy to perform.

3. What are the types of algorithms?


Algorithms are of two types: repetitive and recursive algorithms.

4. Define iterative algorithms.


Algorithms which use loops and conditions to solve the problem are called iterative algorithms.

5. Define recursive algorithms.


Algorithms which perform the recursive steps in a divide and conquer method are called recursive algorithms.

6. What is an array?
An array is a sequential collection of same kind of data elements.

7. What is a data structure?


A data structure is a way of organizing data that considers not only the items stored, but also their relationship to each other.
Advance knowledge about the relationship between data items allows designing of efficient algorithms for the manipulation of
data.

8. Name the areas of application of data structures.The following are the areas of application of data structures:a. Compiler
design
b. Operating system
c. Statistical analysis package
d. DBMS
e. Numerical analysis
f. Simulation
g. Artificial Intelligence
h. Graphics
9. What are the major data structures used in the following areas: Network data model, Hierarchical data model, and
RDBMS?The major data structures used in the above areas are:
Network data model – Graph
Hierarchical data model – Trees
RDBMS – Array

10. What are the types of data structures?


Data structures are of two types: Linear and non linear data structures.

11. What is a linear data structure?


If the elements of a data structure are stored sequentially, then it is a linear data structure.

12. What is non linear data structure?


If the elements of a data structure are not stored in sequential order, then it is a non linear data structure.

13. What are the types of array operations?The following are the operations which can be performed on an array:
Insertion, Deletion, Search, Sorting, Merging, Reversing and Traversal.

14. What is a matrix?


An array of two dimensions is called a matrix.

15. What are the types of matrix operations?The following are the types of matrix operations:
Addition, multiplication, transposition, finding determinant of square matrix, subtraction, checking whether it is singular matrix
or not etc..

1. What is the condition to be checked for the multiplication of two matrices?


If matrices are to be multiplied, the number of columns of first matrix should be equal to the number of rows of second matrix.

2. Write the syntax for multiplication of matrices?Syntax:


for (=0; < value;++)
{
for (=0; < value;++)
{
for (=0; < value;++)
{
arr[var1][var2] += arr[var1][var3] * arr[var3][arr2];
}
}
}

3. What is a string?
A sequential array of characters is called a string.

4. What is use terminating null character?


Null character is used to check the end of string.

5. What is an empty string?


A string with zero character is called an empty string.

6. What are the operations that can be performed on a string?


The following are the operations that can be performed on a string:
finding the length of string, copying string, string comparison, string concatenation, finding substrings etc.

7. What is Brute Force algorithm?


Algorithm used to search the contents by comparing each element of array is called Brute Force algorithm.

8. What are the limitations of arrays?


The following are the limitations of arrays:
Arrays are of fixed size.
Data elements are stored in continuous memory locations which may not be available always.
Adding and removing of elements is problematic because of shifting the locations.

9. How can you overcome the limitations of arrays?


Limitations of arrays can be solved by using the linked list.

10. What is a linked list?


Linked list is a data structure which store same kind of data elements but not in continuous memory locations and size is not
fixed. The linked lists are related logically.

11. What is the difference between an array and a linked list?


The size of an array is fixed whereas size of linked list is variable.
In array the data elements are stored in continuous memory locations but in linked list it is non continuous memory locations.
Addition, removal of data is easy in linked list whereas in arrays it is complicated.

12. What is a node?


The data element of a linked list is called a node.

13. What does node consist of?


Node consists of two fields:
data field to store the element and link field to store the address of the next node.

14. Write the syntax of node creation?Syntax:


struct node
{
data type ;
struct node *ptr; //pointer for link node
}temp;

15. Write the syntax for pointing to next node?Syntax:


node->link=node1;

C ++ Interview Questions Part -1

1. Who has developed C++ and when it has been developed?


C++ was developed by Bjarne Stroustrup in the early 1980’s.

2. What are the languages from which C++ has been evolved?
C & Simula67.

3. What was C++ initially called?


C++ was initially called as “C with classes.

4. What kind of approach is used by C++ top-down or bottom up?


Bottom-up.

5. What are the applications of C++?


C++ has many applications in the real world. It is used to develop compilers, editors, databases, object oriented libraries etc.

6. What is the single line comment used in C++?


Double slash (//) is the single line comment used in C++.
7. What is the multi line comment used in C++.
/*…*/

8. How do you use comments in C++.


Both /*…*/ and // are the comments used in C++. One is multi line comment and the other is single line comment.

9. Can you nest comments in C++.


No.

10. What comments are used for?

a. Documentation of variables and their usage


b. In explaining difficult sections of code.
c. Describes the program, author, date, modification changes, revisions etc.
d. Copyrighting.

11. What is statement terminator in C++?


Semicolon (;)

12. Is C++ language case sensitive or not?


C++ language is case sensitive and the programs are written in lower case.

13. What do you mean by predefined?


The function that has already been written, compiled, and linked together with a program at the time of linking is called
predefined.

14. What does the keyword “void” indicate?


Void indicates that the function does not return any value.

15. What is namespace?


Namespace provides a scope for the identifiers used in the C++ program.

1. What is the default return type of main () in C++?


In C++ int is the default return type of main ().

2. What do you mean by trigraph sequences?


Trigraph sequences help us to enter certain characters that are not available on some keyboards.
Ex.:??/ --- represents ^ (caret)

3. What are tokens in C++?


Smallest individual units are called tokens.

4. What are the types of tokens in C++?


Keywords, identifiers, constants, strings, special symbols, operators.

5. What do you mean keyword?


Keyword has a fixed meaning that cannot be changed
.
6. How many keywords are there in C++ and ANSI C++.In C++ there are 48 keywords plus 15 keywords in ANSI C++.

7. What is single character constant?


A single character enclosed within a pair of single quotes is called single character constant.

8. What is string constant?


Sequence of characters enclosed in double quotes.

9. What are escape sequences?


The combination of backslash (\) and some character together which together represent one character are called escape
sequences.

10. What do you mean by initialization of variable?


Initialization is the process of assigning a value to variable at the time of declaration.

11. What are constants?


The values which do change during program execution are called constants.

12. What are identifiers?


The names of arrays, classes, functions etc created by the user are called identifiers.

13. What are the rules to be followed while naming an identifier?


The following rules are to be followed while naming an identifier:
a. Identifier should not be started with a digit.
b. Alphabetic characters, underscores and digits are to be used.
c. Identifiers are case sensitive.
d. Keywords cannot be used as identifiers.

14. What are the user defined data types in C++?


Class, enum, structure and union are the user defined data types in C++.

15. Name the built in data types in C++.


Integer, float, double, character and void.

1. List few features of object oriented programming.Object oriented programming features:


Follows bottom up approach.
Emphasis is on data.
Programs are divided into objects.
Functions and data are bound together.
Communication is done through objects.
Data is hidden.

2. List features of procedure oriented programming.Procedure oriented programming features:


Follows top down approach.
Emphasis is on procedure.
Programs are divided into functions.
Data moves around freely.

3. What are the basic concepts of OOPs?The following are the basic concepts of OOPs:
Classes, Objects, Data abstraction and encapsulation, Polymorphism, Inheritance, Message Passing, and Dynamic Binding.

4. What is a class?
Class is an entity which consists of member data and member functions which operate on the member data bound together.

5. What is an object?
Objects are instances of classes. Class is a collection of similar kind of objects. When a class is created it doesn’t occupy any
memory, but when instances of class is created i.e., when objects are created they occupy memory space.

6. What is data encapsulation?


Wrapping up of member data and member functions together in a class is called data encapsulation.

7. What is data abstraction?


Data abstraction refers to the act of providing only required features and hiding all the non-essential details for usage.
8. What are ADTs?
ADTs stand for abstract data types. Classes which provide data abstraction are referred to as ADTs.

9. What is inheritance?
The process of inheriting the properties of one object by another object is called inheritance.

10. What is polymorphism?


The feature of exhibiting many forms is called polymorphism.

11. What are the steps involved in message passing?The following are the steps involved in message passing:
Creating classes, creating objects, and creating communication between objects.

12. What is dynamic binding?


The feature that the associated code of a given function is not known till run time is called dynamic binding.

13. What are the advantages of OOP?Data hiding helps create secure programs.
Redundant code can be avoided by using inheritance.
Multiple instances of objects can be created.
Work can be divided easily based on objects.
Inheritance helps to save time and cost.
Easy upgrading of systems is possible using object oriented systems.

14. Give an example for object based programming language.


Ada is an example for object based programming language.

15. Write the features of object based programming language.


Data hiding, data encapsulation, operator overloading and automatic initialization and clear up of objects are the important
features exhibited by object based programming languages.
1. Give some examples of pure object oriented languages.
Eiffel, Java, Simula, Smalltalk are some pure object oriented languages.

2. List the areas of applications of object oriented programming?The following are few areas of applications of object
oriented programming:
CAD/CAM systems
Office automation and decision support systems
Object oriented databases
Real time systems
Simulation and modelling.

3. What is the difference between structure in C and class in C++?


In C structure, by default the members are public. Whereas in C++ class, by default the members are private.

4. What are the sections in class specification?


There are basically two sections in class specification: Class declaration and class function definition.

5. Write the syntax for class declaration.


Syntax:
class
{
private:
variables;
functions;
public:
variables;
functions;
};

6. What are class members?


The variables and functions used in a class are called class members.

7. What are the visibility labels?


Private, public and protected are the visibility labels.

8. Give an example for class declaration.


Ex.:
class area
{
int r;
public:
void get(int r);
void area(int r);
};

9. How does a class provide data hiding?


Data hiding is provided by a class by the use of visibility label private which allows only the member functions to access the data
declared as private.

10. What are the ways of defining member functions?


Member functions can be defined in two ways, one inside the class definition and the other outside the class definition.

11. Write the syntax for defining member functions inside the class.Syntax:
class
{
private:
variables;
public:
variables:
return type
{
statements;
}
};
12. Write the syntax for defining member functions outside the class.Syntax:
return type :: (arguments)
{
body;
}

13. What does member functions represent?


Member functions of a class represent the behaviour of a class.

14. Write the syntax for making an outside function inline?Member functions can be made inline even though we define them
outside the class by using the keyword inline.
Syntax:
class
{
variables;
public:
return type (arguments);
};
inline return type :: (arguments)
{
body;
}

15. What is an object?


A region of storage with associated semantics is called an object.