Arrays Linked List Sorting Wild Pointer Job Interview Questions For Embedded C

1. What are the differences between Arrays and Linked List
Answer:-
  1. Arrays and Linked list both are list data structures used for maintaining a list of values. Arrays use sequential allocation while Linked list uses linked allocation.
  2. Linked list uses some extra memory i.e. link pointer.
  3. Indexing an element, e.g. accessing kth element is cheaper in arrays and costly in Linked list.
  4. Insertion and Deletion of elements is a cheaper operation in Linked lists.
  5. Since nodes in Linked list are dynamically allocated, it has no limitations on growth (apart from memory constraints).
  6. Merging Lists is easier in case of Linked lists.
  7. Breaking a List into two or more lists is easier in case of Linked lists. So Linked list is a better data structure in most cases. Arrays are good mostly for static data structures.
Data Declarations And qualifiers
What is Storage class
Programming Questions for Job Interview
Connections For Atmega16/32 Controllers for Serial Communication

2. What is a wild pointer?
Answer:-Wild pointer is a pointer that doesn't point to either a valid object (of the indicated type, if applicable), or to a distinguished null value, if applicable.



3. What is a BSS Data Segment?
Answer:-BSS, a part of Data Segment store all variables initialized to 0. Static variable(initialized with value other than 0) are not stored in BSS.
BSS is an "Uninitialized RAM" which is initialized to 0 before executing main().

4. When is a switch statement better than multiple if statements?
Answer:-In multiple if statements the conditions are to checked as many times the if statements are written whereas in switch condition the condition is checked only once and jumps to required block .

5. How many types of sorting are there in C?
Answer:-Basically sorting are of two types only:

A. Position Based
1. Selection sort
2. Radix sort
3. Bucket sort, etc.

B. Comparison Based
1. Bubble sort
2. Quick sort
3. Merge sort
4. Binary sort, etc.


6. How to print "n" in C?
Answer:-1. printf("\"n\"");

7. A switch statement cannot include
a) constant as arguments
b) constant expression as arguments
c) string as an argument
d) None of the above
Choose the correct option
Answer:- c) string as an argument


8. What is the output of the following code?
 #include <stdio.h>
void main() {
int s = 0;
while (s++ < 10) {
if (s < 4 && s < 9)
continue;
printf(" %d ", s);
}
}
Options
1) 1 2 3 4 5 6 7 8 9
2) 1 2 3 10
3) 4 5 6 7 8 9 10
4) 4 5 6 7 8 9
Answer:- 3) 4 5 6 7 8 9 10 -The result of the expression s++ is the value of s *before* the increment, so the expression (s++ < 10) operates on the values 0 through 9.In the body of the loop, s has been incremented, so the expression (s < 4 && s < 9) operates on the values 1 through 10. When s is between 1 and 3, the ‘continue’ statement is executed and the loop repeats from the beginning, skipping the printf. So only the values 4 through 10 are written to standard output.

9. What is the output of the following code
printf("%d", printf{"Tim"));

a. Results in a syntax error
b. Outputs Tim3
c. Outputs garbage
d. Prints Tim and terminates abruptly
Answer:- Well yes it gives out a syntax error for the above code.But if it was like this: printf("%d", printf("Tim"));Then the result will be ‘Tim3’, because printf function always returns the number of characters printed...

10. What would be the output of the following program?
main()
{
int y = 128;
const int x = y;
printf("%d", x);
}
a) 128
b) Garbage value
c) Error
d) 0
Answer:- The answer is: 128

Related

Wild Pointer 5644734304651916206

Post a Comment

SPAMMING will not be Appreciated.

emo-but-icon

Hot in week

Recent

Comments

Our Channel

Contact Us

Name

Email *

Message *

Follow by Email

item