Professional Documents
Culture Documents
Topics:
1. Introduction and History
A) Invention and Publication
1. Year and Lab
B) Developer
2. Types, Operator and Expressions
A) Data Type and Sizes
int, float, double, char and long
B) Operators
Arithmetic, relational, Logical operators, bitwise operator, Assignment Operator
C) Expression
Conditional expressions, Precedence
3. Control Flow
A) Control Statements(IF and Else)
B) Loops(while, do-while, for)
C) Jump Statement(break, continue, exit )
4. Function and Program Structure
A) Basics of Function
B) Types of Variables
External, scope, header and register
C) Recursion
5. Pointers and Array
A) Pointers
1. Pointers and Address
2. Pointers and Array
3. Character Pointers
B) Array
1. Introduction
2. Types of Array
6. Structures
A) Basics of Structure
B) Array of Structure
C) Pointers of Structure
D) Structure of Functions
7. Input and Output
A) Standard Input and Output
B) Formatted Output
C) Formatted Input
D) Files Access
1.
2.
Answer Yes. The const modifier means that this code cannot change the value of the
variable, but that does not mean that the value cannot be changed by means outside this
code. For instance, in the example in FAQ 8, the timer structure was accessed through a
volatile const pointer.
The function itself did not change the value of the timer, so it was declared const. However,
the value was changed by hardware on the computer, so it was declared volatile. If a
variable is both const and volatile, the two modifiers can appear in either order.
Q.10 Which bit wise operator is suitable for turning off a particular bit in a number ?
Answer: The bitwise AND operator, again. In the following code snippet, the bit number 24 is
reset to zero.
some_int = some_int & ~KBit24;
Q.11 Which bit wise operator is suitable for putting on a particular bit in a number ?
Answer: The bitwise OR operator. In the following code snippet, the bit number 24 is turned
ON:
some_int = some_int | KBit24;
Q.2 Does there exist any other function which can be used to convert an integer or a float to
a string ?
Answer: Some implementations provide a nonstandard function called itoa(), which converts
an integer to string.
By default function is extern..so it will be visible from other files if the function declaration is
as static..it is invisible for the outer files
3. Static for global variables:
By default we can use the global variables from outside files If it is static global..that variable
is limited to with in the file.
Arrays
Q.2 When does the compiler not implicitly generate the address of the first element of an
array ?
Answer: Whenever an array name appears in an expression such as
Then the compiler does not implicitly generate the address of the address of the first
element of an array.
Q.3 How do you print an address ?
Answer: The safest way is to use printf() (or fprintf() or sprintf()) with the %P specification.
That prints a void pointer (void*). Different compilers might print a pointer with different
formats.
Your compiler will pick a format thats right for your environment.
If you have some other kind of pointer (not a void*) and you want to be very safe, cast the
pointer to a void*:
printf( %Pn, (void*) buffer );
Q.4 What is the difference between array and pointer?
Answer: Pointers are used to manipulate data using the address. Pointers use operator to
access the data pointed to by them.
Arrays is a collection of similar datatype. Array use subscripted variables to access and
manipulate data. Array variables can be Equivalently written using pointer expression.
Q.5 What are the uses of pointer?
Answer: Pointer is used in the following cases
It is used to access array elements.
It is used for dynamic memory allocation.
It is used in Call by reference.
It is used in data structures like trees, graph, linked list etc
Q.6 What is array?
Answer: Array is a variable that hold multiple elements which has the same data type
Answer:Pointers are variables which stores the address of another variable. That variable
may be a scalar (including another pointer), or an aggregate (array or structure). The
pointed-to object may be part of a larger object, such as a field of a structure or an element
in an array.
Structures
Q.1 What is a structure?
Answer:Structure constitutes a super data type which represents several different data types
in a single unit. A structure can be initialized if it is static or global.
Q.2 what is the difference between class and strucrures?
Answer: By default, the members ot structures are public while that tor class is private.
structures doesnt provide something like data hiding which is provided by the
classes.
structures contains only data while class bind both data and member functions.
Q.3 What is self- referential structures?
Answer: A self-referential structure is one of the data structures which refer to the pointer to
(points) to another structure of the same type. For example, a linked list is supposed to be a
self-referential data structure. The next node of a node is being pointed, which is of the
same struct type.
Q.4 What is structure to pointers?
Answer: struct st employee, *stptr;
We point the pointer to employee with the expression stptr = &employee. Then access
the given members by de-referencing the pointer. For this, we have used another structure
just for reading a config file, or a text parser or something more sophisticated. The basic file
operations are
fopen - open a file- specify how its opened (read/write) and type (binary/text)
Reference:
Ritchie Dennis M., (). The C programming Language. 2nd ed. : .
(2012). C Interview Question. [ONLINE] Available at: http://techpreparation.com/.
[Last Accessed 29 May, 2012].