C Interview Paper
C Interview Questions Paper:
1. What is the difference between Char a[ ]=”string” and char *a=”String”
2. What is wrong with the code? The code was for conversion from Celsius to Fahrenheit : degF =5/9*(c+32)
In code this line was wrong as we want 5/9 and that to be multiplied with bracket result. But here 9 will be first multiplied with bracket result.
3. What are Data breakpoints? Give two scenarios where we make the use of this
4. What do you mean by Bit fields? Give example
5. Write the function for changing a number from hexadecimal to integer htoi(s
6. Compare two binary trees they are same or not.
7. You have N computers and [Ca, Cb] means a is connected to b and this connectivity is symmetric and transitive. then write a program which checks that all computers are interconnected and talk two each other
8. WAP to find Depth of tree program. We were given the structure of the node using that we need to write the code.
9. In binary search we have two comparisons one for greater than and other for less than the mid value. Optimize so that we need to check only once
10. Question was some what like we need to write the function so that we get the two dimensional array and memory is assigned to it using malloc function. Don’t remember the question exactly. But this was the only question in proper language
Engineering Paper:
I remember only 5 questions in this. A s this was taken first
1. Binary search Tree was given. Find 4th smallest element.
2. Some code in assembly was given and given five options. What is being calculated?
Ans (XY) 2 + Y + Z
3. Represent (-5)10 in 2’s complement representation in 8 bits
4. Expression was given. Draw tree and then find the postfix
5. Some commands in the assembly language were given. Then need to convert this code in assembly
A=300;
For (i=0 ; i<=10 ; i++)
A=A+200;
c lang is very old lang
it’s not enough i need more questions which covers all topics.
sir,i want to give the some hints about this question….
December 6th, 2007 at 7:56 am, A Says:
Your comment is awaiting moderation.
4. What do you mean by Bit fields? Give example
5. Write the function for changing a number from hexadecimal to integer htoi(s
4. What do you mean by Bit fields? Give example
5. Write the function for changing a number from hexadecimal to integer htoi(s
Q-6)
Compare two binary trees they are same or not.
Sol)
sameTree() Solution (C/C++)
/*
Given two trees, return true if they are
structurally identical.
*/
int sameTree(struct node* a, struct node* b) {
// 1. both empty -> true
if (a==NULL && b==NULL) return(true);
// 2. both non-empty -> compare them
else if (a!=NULL && b!=NULL) {
return(
a->data == b->data &&
sameTree(a->left, b->left) &&
sameTree(a->right, b->right)
);
}
// 3. one empty, one not -> false
else return(false);
}