Cisco Interview Questions Interview Questions in Cisco
1 / 12
// C program using recursion to reverse a string.
# include
void reverseString(char *str)
{
if (*str)
{
reverseString(str+1);
printf("%c", *str);
}
}
int main()
{
char a[] = "India is a great country";
reverseString(a);
return 0;
}
No Tags on this question yet!
2 / 12
To Set Bit use bitwise OR operator (|)
number |= 1 << x;
To clear Bit use bitwise AND operator (&)
number &= ~(1 <
To toggle bit use bitwise XOR operator (^)
number ^= (1 << x)
No Tags on this question yet!
3 / 12
1. Inline follows strict parameter type checking, macros do not.
2. Macros are always expanded by preprocessor, whereas compiler may or may not replace the inline definitions.
3. Compiler has no idea about macros, compiler knows about inline functions.
4. Inline follows strict parameter type checking, macros do not.
5. Macros are always expanded by preprocessor, whereas compiler may or may not replace the inline definitions.
No Tags on this question yet!
4 / 12
LinkedListNode nthToLast(LinkedListNode head, int n) {
if (head == null || n < 1) {
return null;
}
LinkedListNode p1 = head;
LinkedListNode p2 = head;
for (int j = 0; j < n - 1; ++j) { // skip n-1 steps ahead
if (p2 == null) {
return null; // not found since list size < n
}
p2 = p2.next;
}
while (p2.next != null) {
p1 = p1.next;
p2 = p2.next;
}
return p1;
}
No Tags on this question yet!
5 / 12
#define SIZE(type) (size_t)((type *)100 + 1) - (size_t)((type *)100)
No Tags on this question yet!
6 / 12
No Discussion on this question yet!
No Tags on this question yet!
7 / 12
void IsLitttleOrBigEndian()
{
char word = 1;
if((*(char *)& word) == 1 )
printf(“\n Machine is little Indianâ€);
else
printf(“\n Machine is big Indianâ€);
}
No Tags on this question yet!
8 / 12
No Discussion on this question yet!
No Tags on this question yet!
9 / 12
No Discussion on this question yet!
No Tags on this question yet!
10 / 12
#include
Void main() {
int **array;
array = (int **)malloc(nrows * sizeof(int *));
if(array == NULL)
{
fprintf(stderr, "out of memory\n");
return;
}
for(i = 0; i < nrows; i++)
{
array[i] = (int *)malloc(ncolumns * sizeof(int));
if(array[i] == NULL)
{
fprintf(stderr, "out of memory\n");
return;
}
}
for(i = 0; i < nrows; i++)
free(array[i]);
free(array);
}
No Tags on this question yet!
11 / 12
No Discussion on this question yet!
No Tags on this question yet!
12 / 12
No Discussion on this question yet!
No Tags on this question yet!
1 / 17
No Discussion on this question yet!
No Tags on this question yet!
2 / 17
Non-Recursive
========
void reverse(struct node ** head)
{
struct node* prev = NULL;
struct node* current = *head;
struct node* next;
while (current != NULL)
{
next = current->next;
current->next = prev;
prev = current;
current = next;
}
*head = prev;
}
This trick might help you
there are three pointer ( prev, current, next)
next = current*
current* = prev
prev = current
current = next
if we see from above logic then before = is like top to bottom then bottom to top .
* marked pointer will have next.
Recursive
=======
struct node * recLinkedList(struct node *head, struct node *prev)
{
struct node *tmp = head->next;
head->next = prev;
if ( tmp != NULL)
recLinkedList(tmp, head);
return head
}
int main()
{
struct node *head = recLinkedList (head, NULL);
}
No Tags on this question yet!
3 / 17
void Is32BitsOr46Bits()
{
char word = 1;
if((*(char *)& word) == 1 )
printf(“\n Machine is 32 bitsâ€);
else
printf(“\n Machine is 64 bitsâ€);
}
No Tags on this question yet!
4 / 17
No Discussion on this question yet!
No Tags on this question yet!
5 / 17
No Discussion on this question yet!
No Tags on this question yet!
6 / 17
No Discussion on this question yet!
No Tags on this question yet!
7 / 17
No Discussion on this question yet!
No Tags on this question yet!
8 / 17
No Discussion on this question yet!
No Tags on this question yet!
9 / 17
No Discussion on this question yet!
No Tags on this question yet!
10 / 17
No Discussion on this question yet!
No Tags on this question yet!
11 / 17
No Discussion on this question yet!
No Tags on this question yet!
12 / 17
No Discussion on this question yet!
No Tags on this question yet!
13 / 17
No Discussion on this question yet!
No Tags on this question yet!
14 / 17
No Discussion on this question yet!
No Tags on this question yet!
15 / 17
No Discussion on this question yet!
No Tags on this question yet!
16 / 17
No Discussion on this question yet!
No Tags on this question yet!
17 / 17
No Discussion on this question yet!
No Tags on this question yet!
1 / 20
No Discussion on this question yet!
No Tags on this question yet!
2 / 20
No Discussion on this question yet!
No Tags on this question yet!
3 / 20
No Discussion on this question yet!
No Tags on this question yet!
4 / 20
No Discussion on this question yet!
No Tags on this question yet!
5 / 20
No Discussion on this question yet!
No Tags on this question yet!
6 / 20
No Discussion on this question yet!
No Tags on this question yet!
7 / 20
No Discussion on this question yet!
No Tags on this question yet!
8 / 20
No Discussion on this question yet!
No Tags on this question yet!
9 / 20
No Discussion on this question yet!
No Tags on this question yet!
10 / 20
No Discussion on this question yet!
No Tags on this question yet!
11 / 20
No Discussion on this question yet!
No Tags on this question yet!
12 / 20
No Discussion on this question yet!
No Tags on this question yet!
13 / 20
No Discussion on this question yet!
No Tags on this question yet!
14 / 20
No Discussion on this question yet!
No Tags on this question yet!
15 / 20
No Discussion on this question yet!
No Tags on this question yet!
16 / 20
No Discussion on this question yet!
No Tags on this question yet!
17 / 20
No Discussion on this question yet!
No Tags on this question yet!
18 / 20
No Discussion on this question yet!
No Tags on this question yet!
19 / 20
No Discussion on this question yet!
No Tags on this question yet!
20 / 20
No Discussion on this question yet!
No Tags on this question yet!
- Cisco Interview Question Set 1
- >> Cisco Interview Question Set 2
- Cisco Interview Question Set 3
- Cisco Interview Question Set 4
- Cisco Interview Question Set 5
- Cisco Interview Question Set 6
- Cisco Interview Question Set 7
- Cisco Interview Question Set 8
- Cisco Interview Question Set 9
- Cisco Interview Question Set 10
- Cisco Interview Question Set 11
- Cisco Interview Question Set 12
- Cisco Interview Question Set 13