Showing posts with label C Interview Question. Show all posts
Showing posts with label C Interview Question. Show all posts

Wednesday, May 23, 2007

Campus_13 (C Question)

Earn 1860 Rs/Month by reading SMS

Winners of Campus_12 are

1. Ramu Choudhary

2. Subhra Chakraborty


=========================================================

1. What is a const pointer?

Answer: Constant pointer is NOT pointer to constant. Constant pointer means the pointer is constant. For eg:Constant Pointerint * const ptr2 indicates that ptr2 is a pointer which is constant. This means that ptr2 cannot be made to point to another integer. However the integer pointed by ptr2 can be changed.

Where as a Pointer to constant is const int * ptr1 indicates that ptr1 is a pointer that points to a constant integer. The integer is constant and cannot be changed. However, the pointer ptr1 can be made to point to some other integer.

2. How can you determine the maximum value that a numeric variable can hold?

Answer: unsigned int y = 0;
--y;

now check the value of y. This would contain maximum value that an interger can have.now you can determine the values containing by the signed int.

=========================================================


Imprtant:Send answer of Campus_13 (C Question) top 10 right answer sender's name will be published on main page of sandeeoinfo.com
so send your answer quickly.

Process to send answerSend your answer along with your name and your college name to sandeepinfo@yahoo.co.in

Join http://groups.yahoo.com/group/campus_online/ for more updated information

Earn 1860 Rs/Month by reading SMS

Thursday, May 10, 2007

Campus_9 (C Interview Questions)

1. When is a switch statement better than multiple if statements?
Answer: A switch statement is generally best to use when you have more than two conditional expressions based on a single variable of numeric type.

2. What are macros?
Answer: Macros are preprocessors which are small code of snippets which are replaced in the code AS IT IS before compilation of the program.

Preprocessor is a program that processes its input data to produce output that is used as input to another program.

3. What is the difference between goto and longjmp() and setjmp()?
Answer: A goto statement implements a local jump of program execution, and the longjmp() and setjmp() functions implement a nonlocal, or far, jump of program execution.
Generally, a jump in execution of any kind should be avoided because it is not considered good programming practice to use such statements as goto and longjmp in your program.
A goto statement simply bypasses code in your program and jumps to a predefined position. To use the goto statement, you give it a labeled position to jump to. This predefined position must be within the same function. You cannot implement gotos between functions.
When your program calls setjmp(), the current state of your program is saved in a structure of type jmp_buf. Later, your program can call the longjmp() function to restore the program’s state as it was when you called setjmp().Unlike the goto statement, the longjmp() and setjmp() functions do not need to be implemented in the same function. However, there is a major drawback to using these functions: your program, when restored to its previously saved state, will lose its references to any dynamically allocated memory between the longjmp() and the setjmp(). This means you will waste memory for every malloc() or calloc() you have implemented between your longjmp() and setjmp(), and your program will be horribly inefficient. It is highly recommended that you avoid using functions such as longjmp() and setjmp() because they, like the goto statement, are quite often an indication of poor programming practice.

4. What is an lvalue?
Answer: An lvalue is an expression to which a value can be assigned. The lvalue expression is located on the left side of an assignment statement, whereas an rvalue is located on the right side of an assignment statement. Each assignment statement must have an lvalue and an rvalue. The lvalue expression must reference a storable variable in memory. It cannot be a constant.

5. Array is an lvalue or not?
Answer: Basically lvalue is a storage location where data can be stored/ assigned and moreover it is not an expression. rvalue is an expression which has a value. all lvalues can be used as rvalues. But all rvalues can't be used as lvalues. int a[100];a is always an rvalue, but a[i] can be lvalue as well as rvalue

Monday, May 7, 2007

Campus_7 (FAQ's)

Todays Winners are

1. Animesh from JP Institute , NOIDA
2. Mamta Singhar from IGIT, Delhi


Q1: Suppose a 3-bit sequence number is used in the selective-reject ARQ, what is the maximum number of frames that could be transmitted at a time?

A1: If a 3-bit sequence number is used, then it could distinguish 8 different frames. Since the number of frames that could be transmitted at a time is no greater half the numner of frames that could be distinguished by the sequence number, so at most 4 frames can be transmitted at a time

Q2: Describe Stacks and name a couple of places where stacks are useful.
A2: A Stack is a linear structure in which insertions and deletions are always made at one end, called the top. This updating policy is called last in, first out (LIFO). It is useful when we need to check some syntax errors, such as missing parentheses.

Q3: Describe one simple rehashing policy.
A3: The simplest rehashing policy is linear probing. Suppose a key K hashes to location i. Suppose other key occupies H[i]. The following function is used to generate alternative locations:

rehash(j) = (j + 1) mod h

where j is the location most recently probed. Initially j = i, the hash code for K. Notice that this version of rehash does not depend on K.

Q4: Write the pseudo code for the Depth first Search.
A4:
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”


Q5: What are the advantages and disadvantages of B-star trees over Binary trees?
A5: 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.