C Interview Questions
- 4of 4 votes
AnswersGiven a linkedlist, write an algorithm to divide the linkedlist into two linkedlists, the first contains the Fibonacci numbers in the list and the second contains the non-Fibonacci numbers.
- a.ahmed.shalabey October 23, 2015 in United States for Software Development
Test the algorithm after developing the code| Report Duplicate | Flag | PURGE
Amazon SDE1 Algorithm C Data Structures - 0of 0 votes
Answersadd 2 huge numbers represented by linked list. Each linked list element represents a 4 digit number:
- capricornkmu October 17, 2015 in United States for OpenStack
linked list1 : 8798 -> 8765 -> 1243 -> 9856 -> 8888 -> 0914
linked list 2: 8710 -> 5634 -> 1276 -> 8123 -> 1354 -> 9876
output: ................-> ............. ..-> 7980->0243 -> 0790| Report Duplicate | Flag | PURGE
Ebay Software Developer C - 0of 0 votes
Answerswrite a program to validate a IPV4 address
- capricornkmu October 17, 2015 in United States for OpenStack| Report Duplicate | Flag | PURGE
Ebay Software Developer C - 1of 1 vote
Answerswrite a program to toggle certain bits in a integer.
- capricornkmu October 17, 2015 in United States for Networking
Eg.
Inputs : int a, int start bit, int num_of_bits
if a is say 11111010110100000
if start = 6
num_of_bits = 4
output should be (starting 6th bit from right, toggle 4 bits)
11111010001000000| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answerswrite a program to count the 2 letter words in a sentence. Eg. "I am in love with New York" should return 2 (am and in).
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answerwrite a program to find the number when a string is transformed to a palindrome, you can go from higher alphabet to lower alphabet and not the other way:
- capricornkmu October 17, 2015 in United States for Networking
Example:
to convert "abc" to palindrome, 'c' should be changed to 'a'. output should be 2 ('c' - 'a').| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answersfind bugs in the below program:
- capricornkmu October 17, 2015 in United States for Networking
void fn() {
int *i;
i = (int *) malloc (sizeof(int));
return;
}| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answerwrite a program to merge 2 linked list
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answerswrite a program to delete the given node in a BST
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answerwrite to program to find the set bits in an integer
- capricornkmu October 17, 2015 in United States for Networking| Report Duplicate | Flag | PURGE
Hewlett Packard Software Engineer / Developer C - 0of 0 votes
Answerwrite a function to copy string. You are free to decide function parameters. But once you wrote the function, you need to specifically explain below points
- Sach July 20, 2015 in India
- Function parameters
- What are assumptions (For ex. Destination string should have sufficient memory allocated in advance. means function is not going to allocate memory for destination string)
- Limitation of your function
- Find bugs in your code.| Report Duplicate | Flag | PURGE
Hewlett Packard Tech Lead C - 0of 0 votes
AnswersInsert a value into a sorted linked list.
- zsalloum May 01, 2015 in United States
Using C/C++ write a small function (around 5 lines in the body) to insert a value in a sorted linked list. Take into consideration that the list might be empty at first, and the function should cover the cases of insertion at the head and tail...
PS what the interviewer is looking for is the ability to write a small C/C++ code that solves the question and not the algorithm per se which is trivial| Report Duplicate | Flag | PURGE
Microsoft Jr. Software Engineer C C# C++ Linked Lists - -1of 1 vote
Answerswhy its not working?
i am reversing nodes of link list in blocks of k.
here is my codeint hasnode(struct node *s,int k) //checks if k node exist { int i; for(i=1;s&&i<k;i++) s=s->next; if(i==k) return 1; else return 0; } struct node* getkplusoneth_node(struct node **nextnode,int k)//returns k+1th node { int i; for(i=0;*nextnode&&i<k;i++) *nextnode=*nextnode->next; if(i==k) return *nextnode; } void reverseinkblocks(int k) //reverse function { int i; struct node* prev=NULL,*current=head,*nextnode=current,*temp; while(current&&hasnode(current,k)) { *nextnode=getkplusoneth_node(&nextnode,k); while(current!=nextnode)//reverse upto one node before nextnode { temp=current->next; current->next=prev; prev=current; current=temp; } }
}
- pddevesh March 01, 2015 in India| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersIn C,
- programwizard February 19, 2015 in United States
Given a number 18937838393287483, convert it to return into human readable format.
Also, write a test function that will validate the format, show proper error if its invalid.| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answers#include<iostream>
- mukeshsharma787898 January 31, 2015 in United States
#include<stdio.h>
using namespace std;
int main()
{
int i=1;
printf("He");
do
{
while(i<5)
{
cout<<"Hello";
i++;
}
}
while(1);
}
What will be output of the program and why ??
class Demo
{
public static void main(String args[])
{
int i=1;
do
{
while(i<5)
{
System.out.println("Hello");
i++;
}
}
while(true);
}
}
what will be output of java program ??
how it diff ??| Report Duplicate | Flag | PURGE
Nivio Technologies Software Engineer C - 0of 0 votes
Answerswhat is the output of the following and justify ?
- sumit January 07, 2015 in India
#include <stdio.h>
int main()
{
printf(&unix["\0c%set\012"],(unix)["chak"]+"Trick"-0x67);
}| Report Duplicate | Flag | PURGE
Broadsoft Solutions Architect C - 0of 0 votes
Answers#include <stdio.h>
- sumit January 06, 2015 in United States
int main()
{
printf(&unix["\0c%set\012"],(unix)["chak"]+"Trick"-0x67);
}| Report Duplicate | Flag | PURGE
Flipkart Systems Design Engineer C - 0of 0 votes
AnswersImplement strcmp function of stdlib.h library without using any standard library.
- pbsureja December 19, 2014 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer Intern C - 1of 1 vote
AnswersGiven a number,print it in words.
- Pooja Karadgi November 26, 2014 in India
19621 -> One lakh ninety six thousand and twenty one.| Report Duplicate | Flag | PURGE
FactSet Research Systems, Inc Software Engineer / Developer C C++ - 5of 5 votes
Answersint fun() { /*write code here.*/ } int main() { int i=10; fun(); printf("%d",i); }
change the value of the i without changing code of the main function, assign 20 to i ?
- mohit sharma October 28, 2014 in India| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer C - 9of 9 votes
AnswersGiven a string (1-d array) , find if there is any sub-sequence that repeats itself.
- for.anonymous.usa October 22, 2014 in United States
Here, sub-sequence can be a non-contiguous pattern, with the same relative order.
Eg:
1. abab <------yes, ab is repeated
2. abba <---- No, a and b follow different order
3. acbdaghfb <-------- yes there is a followed by b at two places
4. abcdacb <----- yes a followed by b twice
The above should be applicable to ANY TWO (or every two) characters in the string and optimum over time.
In the sense, it should be checked for every pair of characters in the string.| Report Duplicate | Flag | PURGE
Google Software Engineer Intern Algorithm Brain Teasers C C++ Coding Data Structures Dynamic Programming Problem Solving String Manipulation - 1of 3 votes
AnswersA Multi-threaded server application stops working and the last log message from the application is:
"Some Server Related Message..."
Code looks like:
CalledFunc () { Code ... Acquiring Thread lock Line printing "Some Server Related Message..." Func(); Releasing Thread Lock }
1. What should the programmer in charge do to debug this?
- joe.wynton October 07, 2014 in United States for Trading System
2. What has happened wrong in the Func()?
3. If an exception is thrown in the Func() what should be done to fix problem ?| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C# C C++ Threads - 0of 0 votes
AnswersA Multi-threaded server application stops working and the last log message from the application is:
"Some Server Related Message..."
Code looks like:
CalledFunc () { Code ... Acquiring Thread lock Line printing "Some Server Related Message..." Func(); Releasing Thread Lock }
1. What should the programmer in charge do to debug this?
- joe.wynton October 07, 2014 in United States
2. What has happened wrong in the Func() ?
3. If an exception is thrown in the Func() what should be done to fix problem ?| Report Duplicate | Flag | PURGE
Goldman Sachs Software Engineer / Developer C# C C++ Threads - 0of 0 votes
AnswersHow would you implement virtual functions in C?
- iwanna September 24, 2014 in United States| Report Duplicate | Flag | PURGE
Akamai Software Engineer / Developer C - 0of 2 votes
AnswersHow to implement virtual functions in C?
- iwanna September 24, 2014 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C - 1of 1 vote
AnswersWhat do you do if your program does a core dump?
- farzanmoofty August 12, 2014 in United States for Price history
(Analyze code dump)
Name all the possible ways a program would do core dump.| Report Duplicate | Flag | PURGE
Bloomberg LP Software Engineer / Developer C C++ Compiler - 1of 3 votes
AnswersDesign a telephone directory for large ppl (he gave example like design for India). fields will be , first name , last name , number . this should be searchable with first name , last name , number as welll.
- gopi.komanduri July 04, 2014 in India
later added more complexity like do the same for organisation where even it contains designations. so this should be searchable with designations.| Report Duplicate | Flag | PURGE
Analyst Algorithm Arrays C C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Dynamic Programming Hash Table Ideas Large Scale Computing Linked Lists Object Oriented Design Problem Solving Trees and Graphs - 0of 0 votes
AnswersFind the consecutive number of 1s in a unsigned integer?
- leela July 04, 2014 in India
eg suppose you are given 67 the binary equivalent for this is 0b1000011
so here 1 is consecutively appeared 2 time maximum
so 2 is the answer| Report Duplicate | Flag | PURGE
UST global Software Engineer / Developer C - 0of 0 votes
Answersremove a character from the string which does not come simultaneously in c
- gaurav May 27, 2014 in United States
for example, given the string str1 = "120jdvj00ncdnv000ndnv0nvd0nvd0" and the character ch = '0', the output should be 12jdvj00ncdnv000ndnvnvdnvd. That is, the 0 is removed only wherever it occurs singly. this code is not working| Report Duplicate | Flag | PURGE
C