C Interview Questions
- 0of 0 votes
AnswersAn integer n ending with 3 always has a multiple with all 1's. For example 3 has a multiple 111111, 23 has a multiple 11...11. Write a function that takes an integer n and returns string which is the smallest multiple of the n with all 1s
- Joey August 10, 2013 in India| Report Duplicate | Flag | PURGE
Adobe C - 0of 0 votes
Answersnegate each bit of 32 bit integer. I answered with XOR with FFFF but interviewer asked will ~(number) work? I answered as no.
- gaurav.2897 July 30, 2013 in India
I executed this piece of code
int x=8;
int k=~(x);
printf(%d",k)
output: 9
x=1000
~(x) =9 how?| Report Duplicate | Flag | PURGE
McAfee SDE1 C - 0of 0 votes
Answerswhat is difference between array of pointers and pointer to an array?
- Divyasanthi333 July 30, 2013 in United States| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerswrite a code to find the equilibrium position of the array.
- gaurav.2897 July 25, 2013 in India
given an array: 3,-3,8,6,-1,-5
equilibrium position should be 2(element 8) sum of lower index(3+-3)=sum of higher index(6+(-1)+(-5))| Report Duplicate | Flag | PURGE
Amazon SDE1 C - 0of 0 votes
AnswersWrite a program to get shortest path between two given nodes in a binary tree.
- pirate July 18, 2013 in India| Report Duplicate | Flag | PURGE
Amazon Applications Developer C - -5of 7 votes
Answersneed to implement a weather report functionality. user will provide the city name , need to return the weather report.
- gopi.komanduri May 29, 2013 in India
if weather station exists n functioning properly , will return the weather report of that station .
else ,
will return the nearest available weather station report.
interviewer looking for optimized manner.
looking for datastructures to stores the cities n algo to return the report.| Report Duplicate | Flag | PURGE
Mentor Graphics Analyst Algorithm Arrays Bit Manipulation Brain Teasers C C# C++ Cache Coding Computer Architecture & Low Level Data Mining Data Structures Dynamic Programming General Questions and Comments Graphics Hash Table Ideas Linked Lists Math & Computation Object Oriented Design Problem Solving Sets Sorting Stacks String Manipulation Terminology & Trivia Threads Trees and Graphs XML - 0of 0 votes
AnswersIf you are going to debug a program with about 5000 lines of codes (written in C), given that some of its features are working fine while other are not, how are you going to fix it?
- liangzhenxiangsysu May 23, 2013 in United States| Report Duplicate | Flag | PURGE
Student student C - 0of 0 votes
AnswersC program to convert little endian to big endian. Implement htons. ?
- sumit kumar April 16, 2013 in India
Also convert little to big endian using UNIONS ?| Report Duplicate | Flag | PURGE
Developer Program Engineer C - -1of 1 vote
AnswersWrite a program to check whether a substring is present in a main string.
- Raghunath April 11, 2013 in India for Kindle| Report Duplicate | Flag | PURGE
Amazon Testing / Quality Assurance C - 1of 1 vote
AnswersIf an N X N matrix is given, print it in spiral order.
- GKR April 07, 2013 in United States
Example: Below is 5 X 5 matrix
i l o v e
d i n t e
n i e e p
a v w r i
m a x e c
Print in spiral order. Output is iloveepicexamandinterview| Report Duplicate | Flag | PURGE
Epic Systems Algorithm C C++ C# Coding Java - 0of 0 votes
Answerswhat will be the output of the following program and why...
- yeshwantit065 March 29, 2013 in United States for dx#include<conio.h> #include<stdio.h> void main() { int a=10,b=20,diff; diff=&a-&b; printf("Difference=%d",diff); float a1=10.0,b1=20.0; diff=&a1-&b1; printf("\nDifference=%d",diff); char a2='a',b2='z'; diff=&a2-&b2; printf("\nDifference=%d",diff); double a3=10.0,b3=20.0; diff=&a3-&b3; printf("\nDifference=%d",diff); getch(); }
| Report Duplicate | Flag | PURGE
Accenture Software Engineer / Developer C - -1of 1 vote
AnswersIs there any difference between the usage of void pointer and unsigned int ? if yes what the advantage of one over other?
- hprem991 March 19, 2013 in United States
Guys I havn't thought guys commenting here are idiots as well. so please read the detail explanation for it in my below comment. :)| Report Duplicate | Flag | PURGE
Software Architect C - 0of 0 votes
AnswersDesign a Tic Tac Toe Game. Classes Segregation and Code Flow.
- hprem991 March 18, 2013 in India| Report Duplicate | Flag | PURGE
StartUp Amazon Software Architect Software Engineer / Developer Algorithm Android Application / UI Design Arrays Assembly Automata Behavioral Bit Manipulation Brain Teasers C C++ Object Oriented Design - 0of 0 votes
Answerswhite your own printf() function in c ?
- Shrikant March 05, 2013 in India| Report Duplicate | Flag | PURGE
Abs india pvt. ltd. Developer Program Engineer C - 0of 0 votes
Answersvoid populate(char **s); int main() { char *s; populate(&s); printf("%s", s); // should print "Prasad" free(s); return 0; } void populate(char **str) { // 1. The next two lines is one implementation *str = (char *)malloc(sizeof(char) * 7); strcpy(*str, "Prasad"); // 2. This line seperately is another implementation *str = "Prasad"; }
What is wrong, if anything, with the two implementations of populate.
- prasad_usc February 09, 2013 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C - 0of 0 votes
AnswersWhich is best data structure among following for recursion?
- Droid February 06, 2013 in United States
Array
stack
queue
linked list| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWrite a code to extract individual blocks from a given matrix....
- Honey February 02, 2013 in India
Eg: if we have a 4x4 matrix you need to extract 2x2 independent matrices and store them in 4 different arrays...
Given matrix:
1 2 3 4
5 6 7 8
9 10 11 12
13 14 15 16
For the above matrix the output should be as follows..
Array1: 1 2 5 6
Array2: 3 4 7 8
Array3: 9 10 13 14
Array4: 11 12 15 16| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C - 14of 14 votes
AnswersHow volatile is implemented by compiler? is it just by disabling optimization of the code which uses the variables qualified with volatile or something more than that?
- bvgr January 30, 2013 in United States| Report Duplicate | Flag | PURGE
CSR C - 0of 6 votes
AnswersGiven a very very very large integer(with 1 million digits, say), how would you convert this integer to an ASCII string
- Ravi January 24, 2013 in United States for youtube| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer C - -2of 2 votes
AnswersWrite a long running program in C. This program should not hog the CPU, use no sleep()/block()/select()/wait(), should not block resources...and should terminate after a very very very long time
- Ravi January 24, 2013 in United States for youtube| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer C - 0of 0 votes
AnswersHow will you tell whether a given number is a palindrome?
- T January 23, 2013 in United States
Edit: The question was for a string actually.| Report Duplicate | Flag | PURGE
Bloomberg LP Intern C - 0of 0 votes
AnswersHow will you reverse a given number? (not using "/", "&" operators)
- T January 23, 2013 in United States
For eg 756 - > 657| Report Duplicate | Flag | PURGE
Bloomberg LP Intern C - 0of 0 votes
AnswersGiven a BST, how would you return the nth smallest element. The code had to cover all the edge cases and was expected to write a logn solution
- pradeep1288 January 19, 2013 in United States| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C - 0of 0 votes
AnswersWAP to compare string without library function in c??
- patilsanketv December 21, 2012 in United States
1)Program should be designed using Pointers
2)Most efficient i.e lesser number of loops or comparisons??| Report Duplicate | Flag | PURGE
Adobe Developer Program Engineer C - 0of 2 votes
AnswersA log file which has user details(user ID,timestamp) and pages visited in a particular day by that user.The next day -the same kind of log file gets generated.How do you find the probability of users who logged in consecutive days out of the second day - logged in users? The question is simple,but they look for the efficient data structure and time complexity.
- sriramMS December 20, 2012 in United States| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Application / UI Design Arrays Assembly Automata Behavioral Bit Manipulation Brain Teasers C C# C++ Cache Coding Data Mining Data Structures - 0of 0 votes
Answerssuppose you have a string like-I am a king ,
- mayankstg December 14, 2012 in India
in this string you have to write code to count the total number of words which have only single alphabet .for this string answer sholud be 2.| Report Duplicate | Flag | PURGE
Developer Program Engineer C - 2of 2 votes
AnswersGiven a string we have to find first non-repeating character in the string....
- varunesh.88 December 07, 2012 in India
Example: str="aabbbccccddeffffgg";
Answer is : e| Report Duplicate | Flag | PURGE
Morgan Stanley Intern C - 0of 0 votes
AnswersWrite a function to check whether the two strings are rotation of each other or not.
Example: str1="Password" str2="ordPassw"
My Solution was.........
- varunesh.88 December 07, 2012 in India#include<stdio.h> void fn(char * str1, char * str2) { int i=0, j=0,flag=0; while(str2[i]) { if(str2[i]== *str1) { flag=1; break; } i++; } if(!flag) { printf("2nd String is not a rotation of other\n"); return; } j=i; while(str2[i]) { if( !(str2[i]==*str1)) { printf("2nd String is not a rotation of other\n"); return; } i++; str1++; } i=0; while(i<j) { if( !(str2[i]==*str1)) { printf("2nd String is not a rotation of other\n"); return; } i++; str1++; } if(*str1=='\0') printf("String are rotation of each other\n"); else printf("2nd String is not a rotation of other\n"); } int main() { char * str1="Password"; char * str2="ordPassw"; fn(str2, str1); return 0; }
| Report Duplicate | Flag | PURGE
Morgan Stanley Intern C