C Interview Questions
- 0of 0 votes
Answersconstruct a BST given its preorder traversal. solution which i gave :-
- sameersaurav2904 November 29, 2012 in India
make first element of array as node of tree and then if element is less than root and if greater then on right. but i got the answer right for the given example but i am not sure if it was right. can you please suggest me a method to do it.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C - 0of 0 votes
Answerswrite a program with 2 threads. one thread should print even and other should print odd numbers in sequence. how would you make it SMP safe?
- bvgr November 24, 2012 in India| Report Duplicate | Flag | PURGE
Qualcomm C Linux Kernel - 0of 0 votes
AnswersGiven a variable, how can you find whether it was allocated from stack or from heap memory???
- himanshu November 17, 2012 in India| Report Duplicate | Flag | PURGE
Adobe Member Technical Staff C C++ - 0of 0 votes
AnswersHow to write an XOR cipher program using the
- pastorbt November 16, 2012 in United States
C programming language.
Your program must accept as input from the user a value between 0 and 255 to be used as the
secret key, the name of the input file and the name of the output file. No line in the input file
should contain more than 4096 characters.
After the user would have provided their secret key, your program should read and perform an
XOR cipher on the contents of the input file and write the result to the output file.
If the input file has already been encrypted and the identical secret key that was used to
perform the initial encryption is provided, then the contents of the output file should be
deciphered into its original plain text.| Report Duplicate | Flag | PURGE
Student student Student student C - 0of 0 votes
AnswersGiven a word and special characters print all the combinations of that word along with atmost 2 special characters
- Sahil Shah November 13, 2012 in United States
Word - test
special characters 0-9,%,#,&,!
Eg: test, test1, test2, te3st, te1!st, test#%, 12test, !te5st, t0est&, etc. etc.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C - 0of 0 votes
AnswersHow to write an XOR cipher program using the C programming language.
- pastorbt November 08, 2012 in GUYANA
Program must accept as input from the user a value between 0 and 255 to be used as the secret key, the name of the input file and the name of the output file. No line in the input file should contain more than 4096 characters.
After the user would have provided their secret key, your program should read and perform an XOR cipher on the contents of the input file and write the result to the output file.
If the input file has already been encrypted and the identical secret key that was used to perform the initial encryption is provided, then the contents of the output file should be deciphered into its original plain text.
Show:
1, Algorithm and flow chart
2, Source code.
Anyone with a clue to this task?| Report Duplicate | Flag | PURGE
Student student Student student C - 0of 0 votes
AnswersGiven a big string (str1) find (s1) and replace by (s2).
- jayeshr007 November 07, 2012 in India for NOSTG
Example :
str = "Hi i am abc and i am in abc"
s1 = "abc"
s2 = "pqrstuv"
So final o/p :
str1 = "Hi i am pqrstuv in pqrstuv"| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer C - -1of 3 votes
AnswersGiven a number x = 0x25. Convert it into y = 0x25252525.
- Nitin Gupta November 03, 2012 in India| Report Duplicate | Flag | PURGE
Adobe Member Technical Staff Algorithm Bit Manipulation C Coding - 0of 0 votes
Answerint num=1;
- ashishgpt45 November 03, 2012 in United States
*(char*)#
//what this statement does basically
because when it is 1 it means lower order byte is 1 else higher order byte is 1(used for calculating little endian and big endian).| Report Duplicate | Flag | PURGE
C - 1of 1 vote
AnswersFor a given integer X, consisting of not more than 6 digits, write the value of the largest palindrome smaller than X and the value of the smallest palindrome larger than X to output.
- pastorbt October 31, 2012| Report Duplicate | Flag | PURGE
Student student Student student C - 0of 0 votes
Answers(screening round)
- eyeonu.imtiyaz October 30, 2012 in United States
Implement atoi. What would be your approach converting for string to hex.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C - 0of 0 votes
AnswersInput:
- coder_aspirant October 26, 2012 in United States
Given a hexadecimal value:
int i=0x3b24
Output: 0x243b
Some other case:
input: 0x123456
output:0x456123| Report Duplicate | Flag | PURGE
C Microsoft - 0of 0 votes
AnswersState the difference between this two statement.
- Psycho October 23, 2012 in India
char str[] = "/root//foo/bar" ;
char *str = "/root//foo/bar" ;
Now, you have given an assignment str[in1] = str[in2]
where in1 and in2 both initialize with 0.
In first type of declaration no problem. But in second type of declaration 'Segmentation fault' is there. Why this happens?| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer C - -1of 1 vote
AnswersFind the angle between the hands of a clock.
- Survy October 21, 2012 in United States for Visual Studio| Report Duplicate | Flag | PURGE
Microsoft Program Manager C - 0of 0 votes
AnswersWrite a program to read improperly indented C code from a file and add tabs and new lines as per convention in a new file. (Eg. After a control statement is encountered, print the opening brace on a new line. Then, on the line after that, increase indentation and begin writing code. Reduce indentation when a closing brace is encountered by the file pointer).
- sue October 21, 2012 in United States| Report Duplicate | Flag | PURGE
Persistent Systems Software Engineer / Developer C - 0of 0 votes
Answers#include<stdio.h>
- bharat October 19, 2012 in United States
void main()
{int indx=0, a[5];
a[indx]=indx++;
printf("%d",a[indx]);
}
what will be the output?| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerssuppose a matrix A. find a element x in this matrix,x is the smallest in his line but the biggest in his column. Give codes in C
- nz2324nz2324 October 18, 2012 in United States| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWrite a C program to display * for each letter of password you type in command line.
- anuj.iiit2007 October 17, 2012 in United States
Like:Password
********| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersIf there are two threads in your app - T1 and T2. T2 has high priority. However, for some reason the priority decreases automatically. What could be the reason? How will you debug it? How will you fix it so that pririty stays the same, no matter what.
- snehaldesh1 October 05, 2012 in United States| Report Duplicate | Flag | PURGE
Apple Developer Program Engineer C - 1of 1 vote
AnswersHow to store a 100+ digit no. in a variable?
- pulkit.2810 September 20, 2012 in India| Report Duplicate | Flag | PURGE
C C++ - 1of 1 vote
AnswersFind the merging point of 2 given link lists...
- Water September 18, 2012 in United States
I gave him the best O(n) solution i.e by first finding the length of both link list ..........
But he said that he doesn't want an efficient soln. but a soln which is original and cannot be found in any book or over the internet| Report Duplicate | Flag | PURGE
NetApp C - 0of 0 votes
Answerssuppose a structure :
struct itemchar name[15]; int price; long ID; char type[8];
;
- a.bharthan September 15, 2012 in United States
if there is a server running on little endian 64bit machine and a client running on big endian 32bit machine how will client send the structure to server so that the problem of portability, endianness, and alignment does not arise?
client :
sendto(sd,(void *)&myitem, sizeof(item), 0, (struct sockaddr *) &server_addr, sizeof(server_addr));
server:
recvfrom();| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer C - 0of 0 votes
Answers#include<stdio.h>
- Shobhit September 02, 2012 in United States
double fn(char *a , int b , char c)
{
return (1.1);
}
int main()
{
int it = 2;
char ct = 'c';
char a[30];
printf("%d\n",(sizeof(fn)));
return 0;
}
Why the output is 1 ?| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answersnormal bubble sort require 100sec to sort 10000 entries.what will be the input size if it will solve in 50sec.
- Amresh September 02, 2012 in United States| Report Duplicate | Flag | PURGE
McAfee Applications Developer C - 0of 0 votes
Answersint main()
- sushilk.1991 August 25, 2012 in India
{
char *a= "Novell";
char *b;
b=malloc(10*sizeof(char));
memset(b,0,10);
while(*b++=*a++);
printf("%s",b);
return 0;
}| Report Duplicate | Flag | PURGE
Novell Software Engineer / Developer C - 0of 0 votes
AnswersGiven two string, check whether the other is permutation of first one or not.
- androidify August 25, 2012 in United States
Eg: box
xob Ans: True
Eg: box
obxx : Ans: False
This was simple one for Microsoft Developer profile.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C - 1of 1 vote
AnswersGiven a sorted doubly linked list, create a binary tree which is well balanced.
- androidify August 25, 2012 in United States
No example was given in the test.
Used the method similar to binary search.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C - 0of 0 votes
AnswersCheck whether a singly linked list is a pallindrome.
- androidify August 25, 2012 in United States
Eg: 1->2->1 Ans: True
1->3->2->1 Ans: False
I did it by using recursion in O(n) time.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C - 0of 0 votes
AnswersImplement Malloc() and free() functions. How is the allocation done? What data structures are used ? How will you know much memory has to be freed , like in free(ptr) , how much memory has to be freed?
- Zee August 13, 2012 in United States| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer C - 0of 0 votes
AnswersImplement user defined malloc().
- lokesh.cse.nitt August 01, 2012 in India| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C