Documente Academic
Documente Profesional
Documente Cultură
c faqs
Labels: Faqs 1
faqs 2
How do you find out if a linked-list has an end? (i.e. the list is not
a cycle)
You can find out by using 2 pointers. One of them goes 2 nodes each
time. The second one goes at 1 nodes each time. If there is a cycle,
the one that goes 2 nodes each time will eventually meet the one
that goes slower. If that is the case, then you will know the linked-
list is a cycle.
The declaration tells the compiler that at some later point we plan to
present the definition of this declaration.
E.g.: void stars () //function declaration
The definition contains the actual implementation.
E.g.: void stars () // declarator
{
for(int j=10; j > =0; j--) //function body
cout << *; cout <<>
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}
else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0;
cur-> next = head;
for(; curnext!=0; )
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}
#include "iostream.h"
int main() {
int MAX = 4;
int total = 0;
int average;
int numb;
for (int i=0; icout << "Please enter your input between 5 and 9: "; cin
>> numb;
while ( numb<5>9) {
cout << "Invalid input, please re-enter: "; cin >> numb;
}
total = total + numb;
}
average = total/MAX;
cout << "The average number is: " <<>return 0;
}
Create two pointers, each set to the start of the list. Update each
as follows:
while (pointer1) {
pointer1 = pointer1->next;
pointer2 = pointer2->next; if (pointer2) pointer2=pointer2->next;
if (pointer1 == pointer2) {
print (\"circular\n\");
}
}
What is polymorphism?
Answer1
Virtual destructors:
If an object (with a non-virtual destructor) is destroyed explicitly by
applying the delete operator to a base-class pointer to the object,
the base-class destructor function (matching the pointer type) is
called on the object.
There is a simple solution to this problem declare a virtual base-class
destructor.
This makes all derived-class destructors virtual even though they
don’t have the same name as the base-class destructor. Now, if the
object in the hierarchy is destroyed explicitly by applying the delete
operator to a base-class pointer to a derived-class object, the
destructor for the appropriate class is called. Virtual constructor:
Constructors cannot be virtual. Declaring a constructor as a virtual
function is a syntax error.
Answer2
Virtual destructors: If an object (with a non-virtual destructor) is
destroyed explicitly by applying the delete operator to a base-class
pointer to the object, the base-class destructor function (matching
the pointer type) is called on the object.
There is a simple solution to this problem – declare a virtual base-
class destructor. This makes all derived-class destructors virtual
even though they don’t have the same name as the base-class
destructor. Now, if the object in the hierarchy is destroyed explicitly
by applying the delete operator to a base-class pointer to a derived-
class object, the destructor for the appropriate class is called.
Answer1
Array is collection of homogeneous elements.
List is collection of heterogeneous elements.
Answer2
Array uses direct access of stored members, list uses sequencial
access for members.
//With the list you have to cross all previous nodes in order to get
the 5th node:
list mylist;
list::iterator it;
What is a template?
Templates allow to create generic functions that admit any data type
as parameters and return value without having to overload the
function with all the possible data types. Until certain point they fulfill
the functionality of a macro. Its prototype is any of the two following
ones:
You have two pairs: new() and delete() and another pair : alloc
() and free(). Explain differences between eg. new() and malloc
()
Answer1
1.) “new and delete” are preprocessors while “malloc() and free()”
are functions. [we dont use brackets will calling new or delete].
2.) no need of allocate the memory while using “new” but in “malloc
()” we have to use “sizeof()”.
3.) “new” will initlize the new memory to 0 but “malloc()” gives
random value in the new alloted memory location [better to use calloc
()]
Answer2
new() allocates continous space for the object instace
malloc() allocates distributed space.
new() is castless, meaning that allocates memory for this specific
type,
malloc(), calloc() allocate space for void * that is cated to the
specific class type pointer.
What is RTTI?
Runtime type identification (RTTI) lets you find the dynamic type of
an object when you have only a pointer or a reference to the base
type. RTTI is the official way in standard C++ to discover the type of
an object and to convert the type of a pointer or reference (that is,
dynamic typing). The need came from practical experience with C++.
RTTI replaces many homegrown versions with a solid, consistent
approach.
What is encapsulation?
Answer1
POLYMORPHISM : A phenomenon which enables an object to react
differently to the same function call.
in C++ it is attained by using a keyword virtual
Example
public class SHAPE
{
public virtual void SHAPE::DRAW()=0;
}
Note here the function DRAW() is pure virtual which means the sub
classes must implement the DRAW() method and SHAPE cannot be
instatiated
Answer2
class SHAPE{
public virtual Draw() = 0; //abstract class with a pure virtual method
};
class CIRCLE{
public int r;
public virtual Draw() { this->drawCircle(0,0,r); }
};
class SQURE
public int a;
public virtual Draw() { this->drawRectangular(0,0,a,a); }
};
What is an object?
How can you tell what shell you are running on UNIX system?
class Point2D{
int x; int y;
public int color;
protected bool pinned;
public Point2D() : x(0) , y(0) {} //default (no argument) constructor
};
Point2D MyPoint;
You cannot directly access private data members when they are
declared (implicitly) private:
MyPoint.x = 5; // Compiler will issue a compile ERROR
//Nor yoy can see them:
int x_dim = MyPoint.x; // Compiler will issue a compile ERROR
On the other hand, you can assign and read the public data members:
MyPoint.color = 255; // no problem
int col = MyPoint.color; // no problem
With protected data members you can read them but not write them:
MyPoint.pinned = true; // Compiler will issue a compile ERROR
bool isPinned = MyPoint.pinned; // no problem
What is namespace?
Friend classes are used when two or more classes are designed to
work together and need access to each other's implementation in
ways that the rest of the world shouldn't be allowed to have. In
other words, they help keep private things private. For instance, it
may be desirable for class DatabaseCursor to have more privilege to
the internals of class Database than main() has.
What is the word you will use when defining a function in base
class to allow this function to be a polimorphic function?
virtual
Encapsulation.
Labels: Faqs 2
Expressions
● Whats short-circuiting in C expressions?
● Whats wrong with the expression a[i]=i++; ? Whats a
sequence point?
● Does the ?: (ternary operator) return a lvalue? How can I
assign a value to the output of the ternary operator?
● Is 5[array] the same as array[5]?
● What are #pragmas?
● What is the difference between if(0 == x) and if(x == 0)?
● Should we use goto or not?
● Is ++i really faster than i = i + 1?
● What do lvalue and rvalue mean?
● What does the term cast refer to? Why is it used?
● What is the difference between a statement and a block?
● Can comments be nested in C?
● What is type checking?
● Why can't you nest structure definitions?
● What is a forward reference?
● What is the difference between the & and && operators and
the | and || operators?
● Is C case sensitive (ie: does C differentiate between upper
and lower case letters)?
● Can goto be used to jump across functions?
● Whats wrong with #define myptr int *?
● What purpose do #if, #else, #elif, #endif, #ifdef, #ifndef
serve?
● Can we use variables inside a switch statement? Can we use
floating point numbers? Can we use expressions?
● What is more efficient? A switch() or an if() else()?
● What is the difference between a deep copy and a shallow
copy?
● What is operator precedence?
Functions
● How to declare a pointer to a function?
● Does extern in a function declaration mean anything?
● How can I return multiple values from a function?
● Does C support function overloading?
● What is the purpose of a function prototype?
● What are inline functions?
● How to declare an array of N pointers to functions returning
pointers to functions returning pointers to characters?
● Can we declare a function that can return a pointer to a
function of the same type?
● How can I write a function that takes a variable number of
arguments? What are the limitations with this? What is vprintf
()?
● With respect to function parameter passing, what is the
difference between call-by-value and call-by-reference?
Which method does C use?
● If I have the name of a function in the form of a string, how
can I invoke that function?
● What does the error, invalid redeclaration of a function mean?
● How can I pass the variable argument list passed to one
function to another function.
● How do I pass a variable number of function pointers to a
variable argument (va_arg) function?
● Will C allow passing more or less arguments than required to a
function.
● Whats the difference between gets() and fgets()? Whats the
correct way to use fgets() when reading a file?
● How can I have a variable field width with printf?
● How can I specify a variable width in a scanf() format string?
● How can I convert numbers to strings (the opposite of atoi)?
● Why should one use strncpy() and not strcpy()? What are the
problems with strncpy()?
● How does the function strtok() work?
● Why do we get the floating point formats not linked error?
● Why do some people put void cast before each call to printf()?
● What is assert() and when would I use it?
● What do memcpy(), memchr(), memcmp(), memset(), strdup
(), strncat(),strcmp(), strncmp(), strcpy(), strncpy(), strlen(),
strchr(), strchr(),strpbrk(), strspn(), strcspn(), strtok() do?
● What does alloca() do?
● Can you compare two strings like string1==string2? Why do we
need strcmp()?
● What does printf() return?
● What do setjmp() and longjump() functions do?
● Whats the prototype of main()? Can main() return a structure?
● Is exit(status) equivalent to returning the same status from
main()?
● Can main() be called recursively?
● How to print the arguments recieved by main()?
Bit Fiddling
● Write a C program to count bits set in an integer?
● What purpose do the bitwise and, or, xor and the shift
operators serve?
● How to reverse the bits in an interger?
● Check if the 20th bit of a 32 bit integer is on or off?
● How to reverse the odd bits of an integer?
● How would you count the number of bits set in a floating point
number?
File Operations
● How do stat(), fstat(), vstat() work? How to check whether a
file exists?
● How can I insert or delete a line (or record) in the middle of a
file?
● How can I recover the file name using its file descriptor?
● How can I delete a file? How do I copy files? How can I read a
directory in a C program?
● Whats the use of fopen(), fclose(), fprintf(), getc(), putc(),
getw(), putw(), fscanf(), feof(), ftell(), fseek(), rewind(), fread
(), fwrite(), fgets(), fputs(), freopen(), fflush(), ungetc()?
● How to check if a file is a binary file or an ascii file?
Compiling and Linking
● How to list all the predefined identifiers?
● How the compiler make difference between C and C++?
● What are the general steps in compilation?
● What are the different types of linkages?
● What do you mean by scope and duration?
● What are makefiles? Why are they used?
Linked Lists
● How do you reverse a singly linked list? How do you reverse a
doubly linked list? Write a C program to do the same.
● Given only a pointer to a node to be deleted in a singly linked
list, how do you delete it?
● How do you sort a linked list? Write a C program to sort a
linked list.
● How to declare a structure of a linked list?
● Write a C program to implement a Generic Linked List.
● How do you reverse a linked list without using any C pointers?
● How would you detect a loop in a linked list? Write a C
program to detect a loop in a linked list.
● How do you find the middle of a linked list? Write a C program
to return the middle of a linked list
● If you are using C language to implement the heterogeneous
linked list, what pointer type will you use?
● How to compare two linked lists? Write a C program to
compare two linked lists.
● How to create a copy of a linked list? Write a C program to
create a copy of a linked list ?
● Write a C program to free the nodes of a linked list.
● Can we do a Binary search on a linked list?
● Write a C program to return the nth node from the end of a
linked list.
● How would you find out if one of the pointers in a linked list is
corrupted or not?
● Write a C program to insert nodes into a linked list in a sorted
fashion?
● Write a C program to remove duplicates from a sorted linked
list?
● How to read a singly linked list backwards?
● How can I search for data in a linked list?
Trees
● Write a C program to find the depth or height of a tree.
● Write a C program to determine the number of elements (or
size) in a tree.
● Write a C program to delete a tree (i.e, free up its nodes)
● Write C code to determine if two trees are identical
● Write a C program to find the mininum value in a binary search
tree.
● Write a C program to compute the maximum depth in a tree?
● Write a C program to create a mirror copy of a tree (left nodes
become right and right nodes become left)!
● Write C code to return a pointer to the nth node of an inorder
traversal of a BST.
● Write C code to implement the preorder(), inorder() and
postorder() traversals. Whats their time complexities?
● Write a C program to create a copy of a tree
● Write C code to check if a given binary tree is a binary search
tree or not?
● Write C code to implement level order traversal of a tree.
● Write a C program to delete a node from a Binary Search Tree?
● Write C code to search for a value in a binary search tree
(BST).
● Write C code to count the number of leaves in a tree
● Write C code for iterative preorder, inorder and postorder tree
traversals
● Can you construct a tree using postorder and preorder
traversal?
● Construct a tree given its inorder and preorder traversal
strings. Similarly construct a tree given its inorder and post
order traversal strings.
● Find the closest ancestor of two nodes in a tree.
● Given an expression tree, evaluate the expression and obtain a
paranthesized form of the expression.
● How do you convert a tree into an array?
● What is an AVL tree?
● How many different trees can be constructed using n nodes?
● A full N-ary tree has M non-leaf nodes, how many leaf nodes
does it have?
● Implement Breadth First Search (BFS) and Depth First Search
(DFS)
● Write pseudocode to add a new node to a Binary Search Tree
(BST)
● What is a threaded binary tree?
Sorting
● What is heap sort?
● What is the difference between Merge Sort and Quick sort?
● Give pseudocode for the mergesort algorithm
● Implement the bubble sort algorithm. How can it be improved?
Write the code for selection sort, quick sort, insertion sort.
● How can I sort things that are too large to bring into memory?
C++ on Unix
1. What is a Make file?(Fujitsu) Make file is a utility in Unix to
help compile large programs. It helps by only compiling the
portion of the program that has been changed.
2. What is deadlock? (Novell) Deadlock is a situation when two
or more processes prevent each other from running.Example: if
T1 is holding x and waiting for y to be free and T2 holding y
and waiting for x to be free deadlock happens.
3. What is semaphore? (Novell) Semaphore is a special
variable, it has two methods: up and down. Semaphore
performs atomic operations, which means ones a semaphore is
called it can not be inturrupted.
4. Is C an object-oriented language? (Microsoft) C is not an
object-oriented language, but limited object-oriented
programming can be done in C.
5. Name some major differences between C++ and Java.
C++ has pointers; Java does not. Java is platform-independent;
C++ is not. Java has garbage collection; C++ does no
There are two formats for initializers in C++ as shown in the example
that follows. The first format uses the traditional C notation. The
second format uses constructor notation.
Q: Explain the ISA and HASA class relationships. How would you
implement each in a class design?
A: A specialized class "is" a specialization of another class and,
therefore, has the ISA relationship with the other class. An Employee
ISA Person. This relationship is best implemented with inheritance.
Employee is derived from Person. A class may have an instance of
another class. For example, an employee "has" a salary, therefore the
Employee class has the HASA relationship with the Salary class. This
relationship is best implemented by embedding an object of the
Salary class in the Employee class.
❍ Destructor
❍ Copy constructor
❍ Assignment operator
❍ Find substring
class Fruit {
// …
}
// Container of fruit
class BasketOfFruit {
BasketOfFruit() ;
void insert( Fruit & f ) ;
// …
}
// Container of apples
class BasketOfApples /* ??? */ {
// …
}
int f( char *p ) {
int n = 0 ;
while ( *p != 0 ) n = 10*n + *p++ - ‘0′ ;
return n ;
}
struct s {
struct s *next ;
}
class Empty
{
};
Disk : This class is a singleton. The read() and write() methods both
block on a simple atomic lock()/unlock() shared between the two. (ie,
only one thread can access the disk, thru either read or write, at any
given time). It also has a waitForData() method, which blocks
(without claiming the lock) until either a timeout elapses, or data is
ready. It returns true upon returning due to new data, false upon
returning due to the timeout.
Thread 1: (priority: 5)
while(!Disk.waitForData()) { yield(); } /* Wait until
someone has
written data to the disk */
Network.write(Disk.read()); /* Write the data buffered on
the disk to
the network */
Thread 2: (priority: 2)
while(!Sensor.waitForData()) { yield(); } /* Wait until
the sensors
have picked up data */
Disk.write(Sensor.processData()); /* process the data and
write it to
the disk. */
Thread 3: (priority: 1)
Thread 4: (priority: 4)
if (checkAlarms()) /* If any serious alarms exist */
Disk.write(AlarmData); /* Buffer that data to disk for
immediate
network transmit */
yield();
A1 B-star trees have better data structure and are faster in search
than Binary trees, but it’s harder to write codes for B-start trees.
A2
dfs(G, v) //OUTLINE
Mark v as "discovered"
For each vertex w such that edge vw is in G:
If w is undiscovered:
dfs(G, w); that is, explore vw, visit w, explore from there
as much as possible, and backtrack from w to v.
Otherwise:
"Check" vw without visiting w.
Mark v as "finished".
rehash(j) = (j + 1) mod h
C++ Networking
Question
Q: What is the difference between Stack and Queue?
char *str;
err_num = 2;
return (str);
while(len)
str[i++]=s[–len];
str[i] = NULL;
return (str);
3) Implementation (coding)
4) Testing
6) Obsolescence
Q: What is the difference between a Java application and a Java
applet?
A: -Application layer
-Presentation layer
-Session layer
-Transport layer
-Network layer
-Physical layer
void reverselist(void)
{
if(head==0)
return;
if(head->next==0)
return;
if(head->next==tail)
{
head->next = 0;
tail->next = head;
}
else
{
node* pre = head;
node* cur = head->next;
node* curnext = cur->next;
head->next = 0;
cur->next = head;
for(; curnext!=0; )
{
cur->next = pre;
pre = cur;
cur = curnext;
curnext = curnext->next;
}
curnext->next = cur;
}
}
2. What is polymorphism?
3. How do you find out if a linked-list has an end? (i.e. the list is
not a cycle)
You can find out by using 2 pointers. One of them goes 2 nodes each
time. The second one goes at 1 nodes each time. If there is a cycle,
the one that goes 2 nodes each time will eventually meet the one
that goes slower. If that is the case, then you will know the linked-
list is a cycle.
4. How can you tell what shell you are running on UNIX system?
(From IBM) What classes you have enjoyed the most during
your school years?
Answer: I like the class I am taking this semester, which involves a
group project that needs great amount of team efforts. I really enjoy
work with a group of people because we can learn new materials
mutually.
>
❍ inheritance
❍ polymorphism
main()
{
char *p1=“name”;
char *p2;
p2=(char*)malloc(20);
memset (p2, 0, 20);
while(*p2++ = *p1++);
printf(“%s\n”,p2);
Answer:empty string.
2. What will be printed as the result of the operation below:
main()
{
int x=20,y=35;
x=y++ + x++;
y= ++y + ++x;
printf(“%d%d\n”,x,y);
Answer : 5794
3. What will be printed as the result of the operation below:
main()
{
int x=5;
printf(“%d,%d,%d\n”,x,x< <2,x>>2);
Answer: 5,20,1
4. What will be printed as the result of the operation below:
void main()
{
int x=5, y=10;
swap (x,y);
printf(“%d %d\n”,x,y);
swap2(x,y);
printf(“%d %d\n”,x,y);
}
int swap2(int a, int b)
{
int temp;
temp=a;
b=a;
a=temp;
return 0;
Answer: 10, 5
10, 5
5. What will be printed as the result of the operation below:
main()
{
char *ptr = ” Cisco Systems”;
*ptr++; printf(“%s\n”,ptr);
ptr++;
printf(“%s\n”,ptr);
Answer:Cisco Systems
isco systems
6. What will be printed as the result of the operation below:
main()
{
char s1[]=“Cisco”;
char s2[]= “systems”;
printf(“%s”,s1);
}
Answer: Cisco
7. What will be printed as the result of the operation below:
main()
{
char *p1;
char *p2;
p1=(char *)malloc(25);
p2=(char *)malloc(25);
strcpy(p1,”Cisco”);
strcpy(p2,“systems”);
strcat(p1,p2);
printf(“%s”,p1);
Answer: Ciscosystems
8. The following variable is available in file1.c, who can access it?:
Answer: all the functions in the file1.c can access the variable.
9. WHat will be the result of the following code?
while(TRUE)
{
// some code
int x;
int modifyvalue()
{
return(x+=10);
}
int changevalue(int x)
{
return(x+=1);
}
void main()
{
int x=10;
x++;
changevalue(x);
x++;
modifyvalue();
printf("First output:%d\n",x);
x++;
changevalue(x);
printf("Second output:%d\n",x);
modifyvalue();
printf("Third output:%d\n",x);
Answer: 12 , 13 , 13
11. What will be printed as the result of the operation below:
main()
{
int x=10, y=15;
x = x++;
y = ++y;
printf(“%d %d\n”,x,y);
Answer: 11, 16
12. What will be printed as the result of the operation below:
main()
{
int a=0;
if(a==0)
printf(“Cisco Systems\n”);
printf(“Cisco Systems\n”);
Good C interview
Questions
1.
C interview questions
1 What
Interviewing Questions does
Sample questions & safe interviewing tips you can use now. static
WorkforceCentralFlorida.com
variable
mean?
Interview Answer Guide 2. What is a
Impress your interviewer and Get Hired for the job you want pointer?
www.JobInterviewTools.com
3. What is a
structure?
Behavioral Interview?
Word-for-Word Exactly What You Need To Say To Get Hired - 4. What are
Check it out! the
Behavior.Job-Interview-Answers.com differences
Java/J2EE interview Q&A between
400+ popular questions & answers with lots diagrams, examples, structures
code and
www.lulu.com/java-success
arrays?
5. In header
files
Interview Questions
whether
Find The Answers To Technical Interview Questions Here!
InterviewQuestionAndAnswer.com functions
are
Find Interview Questions declared
Ace Your Next Interview. Get 1000s Of Sample Questions. Browse or
Today! defined?
www.Vault.com
6. What are
Job Applicant Mistakes the
Five Common Job Applicant Mistakes & How to Avoid Them at differences
DiversityInc
www.DiversityInc.com between
malloc()
Software Jobs In Dallas and calloc
Verification and testing careers RIM is hiring today. Join a leader. ()?
www.Rim.com/careers
7. What are
macros?
What are
the
advantages and disadvantages?
8. Difference between pass by reference and pass by value?
9. What is static identifier?
10. Where are the auto variables stored?
11. Where does global, static, local, register variables, free
memory and C Program instructions get stored?
12. Difference between arrays and linked list?
13. What are enumerations?
14. Describe about storage allocation and scope of global,
extern, static, local and register variables?
15. What are register variables? What are the advantage of
using register variables?
16. What is the use of typedef?
17. Can we specify variable field width in a scanf() format
string? If possible how?
18. Out of fgets() and gets() which function is safe to use and
why?
19. Difference between strdup and strcpy?
20. What is recursion?
21. Differentiate between a for loop and a while loop? What
are it uses?
22. What are the different storage classes in C?
23. Write down the equivalent pointer expression for referring
the same element a[i][j][k][l]?
24. What is difference between Structure and Unions?
25. What the advantages of using Unions?
26. What are the advantages of using pointers in a program?
27. What is the difference between Strings and Arrays?
28. In a header file whether functions are declared or defined?
29. What is a far pointer? where we use it?
30. How will you declare an array of three function pointers
where each function receives two ints and returns a float?
31. What is a NULL Pointer? Whether it is same as an
uninitialized pointer?
32. What is a NULL Macro? What is the difference between a
NULL Pointer and a NULL Macro?
33. What does the error ‘Null Pointer Assignment’ mean and
what causes this error?
34. What is near, far and huge pointers? How many bytes are
occupied by them?
35. How would you obtain segment and offset addresses from
a far address of a memory location?
36. Are the expressions arr and *arr same for an array of
integers?
37. Does mentioning the array name gives the base address in
all the contexts?
38. Explain one method to process an entire string as one unit?
39. What is the similarity between a Structure, Union and
enumeration?
40. Can a Structure contain a Pointer to itself?
41. How can we check whether the contents of two structure
variables are same or not?
42. How are Structure passing and returning implemented by
the complier?
43. How can we read/write Structures from/to data files?
44. What is the difference between an enumeration and a set
of pre-processor # defines?
45. What do the ‘c’ and ‘v’ in argc and argv stand for?
46. Are the variables argc and argv are local to main?
47. What is the maximum combined length of command line
arguments including the space between adjacent
arguments?
48. If we want that any wildcard characters in the command
line arguments should be appropriately expanded, are we
required to make any special provision? If yes, which?
49. Does there exist any way to make the command line
arguments available to other functions without passing
them as arguments to the function?
50. What are bit fields? What is the use of bit fields in a
Structure declaration?
51. To which numbering system can the binary number
1101100100111100 be easily converted to?
52. Which bit wise operator is suitable for checking whether a
particular bit is on or off?
53. Which bit wise operator is suitable for turning off a
particular bit in a number?
54. Which bit wise operator is suitable for putting on a
particular bit in a number?
55. Which bit wise operator is suitable for checking whether a
particular bit is on or off?
56. Which one is equivalent to multiplying by 2?
❍ Left shifting a number by 1
returns nothing
80. What do the functions atoi(), itoa() and gcvt() do?
81. Does there exist any other function which can be used to
convert an integer or a float to a string?
82. How would you use qsort() function to sort an array of
structures?
83. How would you use qsort() function to sort the name
stored in an array of pointers to string?
84. How would you use bsearch() function to search a name
stored in array of pointers to string?
85. How would you use the functions sin(), pow(), sqrt()?
86. How would you use the functions memcpy(), memset(),
memmove()?
87. How would you use the functions fseek(), freed(), fwrite()
and ftell()?
88. How would you obtain the current time and difference
between two times?
89. How would you use the functions randomize() and random
()?
90. How would you implement a substr() function that extracts
a sub string from a given string?
91. What is the difference between the functions rand(),
random(), srand() and randomize()?
92. What is the difference between the functions memmove()
and memcpy()?
93. How do you print a string on the printer?
94. Can you use the function fprintf() to display the output on
the screen?
95. What is a linklist and why do we use it when we have
arrays? - I feel the correct answer should be linklist is used
in cases where you don’t know the memory required to
store a data structure and need to allocate is dynamically
on demand.
96. How do you detect a loop in linked list?
97. What is the difference between main() in C and main() in
C++?
98. what will be printed out when the following code is
executed:
main()
{
printf("%x",-1<<4);>
99. Programming
Interviews Questions
100. How can you defined OOP?
101. How can you use OOP in your
projects/products/applications?
102. What is copy constructor?
103. How many types of copy constructor are there?
104. What shallow copy constructor does/behaves?
105. Does C++ support copy constructor?
106. Does Java support copy constructor?
107. (If the answer to the previous question was correct) Why
doesn’t Java support copy constructor?
108. What is software life cycle?
Interviewing Questions
Sample questions & safe interviewing tips you can use now.
WorkforceCentralFlorida.com
Interview questions
Find Only Six Figure Jobs Search 25,000 Openings
www.TheLadders.com
class test
{
int x,y;
public:
test()
{
x=0; y=0;
}
void mod()
{
x=10;
y=15;
}
};
class Sample
{
public:
int *ptr;
Sample(int i)
{
ptr = new int(i);
}
~Sample()
{
delete ptr;
}
void PrintVal()
{
cout << "The value is " <<
*ptr; } }; void SomeFunc(Sample x) {
cout << "Say i am in someFunc " << s1 =" 10;">
Method
constructor.
❍ The condition should hold at the end of every mutator
(non-const) operation.
19. What are proxy objects? Objects that stand for other
objects are called proxy objects or surrogates.
template
class Array2D
{
public:
class Array1D
{
public:
T& operator[] (int index);
const T& operator[] (int index)const;
};
Array1D operator[] (int index);
const Array1D operator[] (int index) const;
};
Array2Ddata(10,20);
cout<
class,
❍ relies primarily on virtual functions in its public interface
Interview questions on
C/C++
Q1: Tell how
Interviewing Questions to check
Sample questions & safe interviewing tips you can use now. whether a
WorkforceCentralFlorida.com
linked list is
circular.
Java/J2EE interview Q&A
400+ popular questions & answers with lots diagrams, examples,
code A: Create two
www.lulu.com/java-success pointers, each
Interview Answer Guide set to the
Increase your chance of being hired With easy to follow answer start of the
guide. list. Update
www.JobInterviewTools.com
each as
follows:
interview questions
Find 70,000 jobs that pay over $100,000. Search now.
www.TheLadders.com while
(pointer1) {
pointer1 =
pointer1-
Interview Answer Guide >next;
Increase your chance of being hired With easy to follow
pointer2 =
answer guide.
www.JobInterviewTools.com pointer2-
>next; if
(pointer2)
Memory Analyzer from SAP pointer2=poin
Download Java Heap Dump Analyzer Free From SAP ter2->next;
Developer Network.
SAP.com if (pointer1
== pointer2)
{
Java Training print
Accelerated, Professional Java Training & Certification. ("circularn")
Get Info!
www.TrainingCamp.com ;
}
}
How can you find the nodes with repetetive data in a linked list?
Write a prog to accept a given string in any order and flash error
if any of the character is different. For example : If abc is the
input then abc, bca, cba, cab bac are acceptable but aac or bcd are
unacceptable.
#include
main()
{
typedef union
{
int a;
char b[10];
float c;
}
Union;
Union x,y = {100};
x.a = 50;
strcpy(x.b,"hello");
x.c = 21.50;
printf("Union x : %d %s %f n",x.a,x.b,x.c );
printf("Union y :%d %s%f n",y.a,y.b,y.c);
}
Windows Programming
Interview Questions
1. What are
Software Jobs In Dallas kernel
objects? - -
Verification and testing careers RIM is hiring today. Join a leader.
www.Rim.com/careers
Several types
of kernel
Interviewing Questions objects, such
Sample questions & safe interviewing tips you can use now. as access
WorkforceCentralFlorida.com
token objects,
event objects,
Java/J2EE interview Q&A
400+ popular questions & answers with lots diagrams, examples, file objects,
code file-mapping
www.lulu.com/java-success objects, I/O
Memory Analyzer from SAP completion
Download Java Heap Dump Analyzer Free From SAP Developer port objects,
Network. job objects,
SAP.com
mailslot
objects, mutex
objects, pipe
Interview Answer Guide objects,
Increase your chance of being hired With easy to follow process
answer guide.
www.JobInterviewTools.com objects,
semaphore
objects,
Memory Analyzer from SAP thread
Analyze Java Heap Dumps. Download Memory Analyzer objects, and
Tool from SAP. waitable timer
SAP.com
objects.
2. What is a
Java Training kernel
Professional Java Training & Cert. Guaranteed Cert. View object? -
Courses Now! Each kernel
www.TrainingCamp.com
object is
simply a
memory block
allocated by
the kernel and is accessible only by the kernel. This memory
block is a data structure whose members maintain information
about the object. Some members (security descriptor, usage
count, and so on) are the same across all object types, but
most are specific to a particular object type. For example, a
process object has a process ID, a base priority, and an exit
code, whereas a file object has a byte offset, a sharing mode,
and an open mode.
3. User can access these kernel objects structures? - Kernel
object data structures are accessible only by the kernel
4. If we cannot alter these Kernel Object structures directly,
how do our applications manipulate these kernel objects? -
The answer is that Windows offers a set of functions that
manipulate these structures in well-defined ways. These kernel
objects are always accessible via these functions. When you
call a function that creates a kernel object, the function
returns a handle that identifies the object.
5. How owns the Kernel Object? - Kernel objects are owned by
the kernel, not by a process
6. How does the kernel object outlive the process that
created it? - If your process calls a function that creates a
kernel object and then your process terminates, the kernel
object is not necessarily destroyed. Under most circumstances,
the object will be destroyed; but if another process is using the
kernel object your process created, the kernel knows not to
destroy the object until the other process has stopped using it
7. Which is the data member common to all the kernel object
and what is the use of it? -