C Interview Questions
- 1of 1 vote
AnswersQ3. Written Exam Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a singly linked list which may or may not contain loop and loop may or may not start from the head node. Count the number of elements in the linked list.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm C C# C++ Coding Data Structures Java Linked Lists - 0of 0 votes
AnswersQ2. Written Exam Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a number in the form of string. Output the binary equivalent of that number.
Sample Input: "8.5"
Sample Output: 1000.1
Sample Input: "12.34.23"
Sample Output: "ERROR"| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm C C# C++ Coding Java Math & Computation - 0of 0 votes
AnswersExplain the problem with following c code:
- anuj.iiit2007 May 11, 2012 in United States
IN file1.c we define
int myarray[10];
IN file2.c we uses 'myarray' as,
extern int*myarray;
void foo()
{
myarray[0]=10;
}| Report Duplicate | Flag | PURGE
C - 1of 1 vote
AnswersAssuming there's no Array data structure in C, how would you implement it.
- chandan.jc May 10, 2012 in United States for System Software| Report Duplicate | Flag | PURGE
NVIDIA Intern C - 0of 0 votes
Answersx = x++ + ++y;
- Lively May 06, 2012 in United States
y = ++x + ++y;
what are the values of x,y after these are executed ?| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer C - 0of 0 votes
Answersreverse the words in a sentence: "hello world" -> "world hello"
- Lively May 06, 2012 in United States| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer C - 0of 0 votes
AnswersDifference between constant char pointer and constant pointer to a char.
- dareyouspam May 06, 2012 in United States| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer / Developer C - 0of 0 votes
AnswersCode to find endianness of a machine.
- dareyouspam May 06, 2012 in United States| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer / Developer C Coding - 0of 0 votes
AnswersWrite a code that will check whether the memory allotted to the program at the initial and the memory returned to the system is same or not.
- Learn Android: http://learnandroideasily.blogspot.in/ May 04, 2012 in India| Report Duplicate | Flag | PURGE
Adobe Software Engineer / Developer C - 0of 0 votes
Answersremove spaces when they occur more than one time consecutively in string.
- jdicky May 03, 2012 in United States#include<stdio.h> #include<string.h> #include<stdlib.h> #define SPACE ' ' main() { char string[100], *blank, *start; int length, c = 0, d = 0; printf("Enter a string\n"); gets(string); length = strlen(string); blank = string; start = (char*)malloc(length+1); if ( start == NULL ) exit(EXIT_FAILURE); while(*(blank+c)) { if ( *(blank+c) == SPACE && *(blank+c+1) == SPACE ) {} else { *(start+d) = *(blank+c); d++; } c++; } *(start+d)='\0'; printf("%s\n", start); free(start); return 0;
| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer C - 0of 0 votes
AnswersWhat does the following program do ?
- Vezita May 02, 2012 in India
main ()
{
unsigned int num ;
int i ;
scanf("%u ", &num);
for(i=0;i<16;1++)
printf("%d",(num<<i & 1<<15) ? 1:0);
}
A. print all even bits from num
B. print all odd bits from num
C. prints binary equivalent of num| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer C - 0of 0 votes
Answers1.
x = 5; y = 6; x = y++ + x++; y = ++y + ++x; printf("%d.....%d", x, y);
2. How function pointer works?
- rasmiranjanbabu April 27, 2012 in India
3. **p vs &(*p)
4. int a[10]; how you allocate memory for the same; should be compiler independent.| Report Duplicate | Flag | PURGE
Dover Organization Developer Program Engineer C - -1of 1 vote
Answersprint 2n+1 prime numbers if any one of them not prime then print factors for that number
- Anonymous April 21, 2012 in India| Report Duplicate | Flag | PURGE
Facebook Developer Program Engineer Arrays C Coding - 0of 0 votes
Answerswhat is the output
- istiyak916 April 21, 2012 in India
main()
{
char x=-1>>2;
printf("%d",x);
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerswhat is difference between " return " and " exit ".
- istiyak916 April 17, 2012 in India| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerswap to input any number and double it without using any operator
- istiyak916 April 17, 2012 in India| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersDesign a structure for a student record which has following 3 fields-
- rising April 14, 2012 in India
ID - integer value
Name - String
either a grade - which is float value OR rank - which is integer value.
Also write a function to print the details of a student record such that if the student is given grade it must be printed as float value but if he is given rank then it must be printed as integer value.| Report Duplicate | Flag | PURGE
Oracle Software Engineer / Developer C - 0of 0 votes
AnswersWrite a function in C to efficiently copy 1 file to another.
- rising April 14, 2012 in India| Report Duplicate | Flag | PURGE
Oracle Software Engineer / Developer C - 0of 0 votes
AnswersWhich one of these is a keyword in C? (a) printf (b) #define (c) sizeof (d) ->
- gigo April 05, 2012 in India| Report Duplicate | Flag | PURGE
RSA Intern C - 0of 0 votes
AnswersWhat is the declaration of a function that returns a pointer to a function which has int * argument and return type void? First show how it can be declared without typedef. Next show, how it may be written neatly using typedef.
- gigo April 05, 2012 in India| Report Duplicate | Flag | PURGE
RSA Software Engineer / Developer C - 0of 0 votes
Answermalloc implementation
- DJ March 31, 2012 in United States
malloc allocation & stack allocation compare
Detailed questions on projects| Report Duplicate | Flag | PURGE
NetApp Intern C - 0of 0 votes
AnswerBinu is an aspiring pattern-artist. He spends his free time creating patterns using the computer keyboard. One day, he was creating a random pattern using “/”and “\” characters and during the process, realized that his pattern contained open paths and enclosures (see figure alongside). In this figure, Binu has drawn 6 characters (using either “/” or “\”) each in 4 rows on a standard graph paper. He counted two enclosures (marked with dots), the larger one of 16 squares size and the smaller one of 4 squares size. He also noticed several open paths (non-closed spaces) which are not relevant in the context of this problem. Your task is to help Binu by writing a program that counts all the enclosures in a given pattern and find the size of the largest enclosure. For simplicity, we will not dwell into cases where there are enclosures within enclosures (your code doesn’t need to consider such cases). You may note in the figure that each “/” or “\” is equivalent to 2 units in the graph.
- Master March 29, 2012 in India
Input:-
The input file would contain multiple independent test cases, each test case being a pattern, drawn by Binu. Each test case begins with two integers a and b (1 <= a <= 50, 1 <= b <= 50) where a and b represents the length and breadth of the pattern. The next b lines contain a characters each which are either “/” or “\” (no whitespaces in between). The input ends with a test case having a and b as 0. In the above figure, a = 6, b = 4.
Output:-
For each test case, your code needs to output (on a separate line) two integers x and y (separated by a single whitespace) where x is the total number of enclosures in that pattern and y is the size of the biggest enclosure. In the above figure, the output would be 2 16; meaning, there are 2 enclosures & the size of the largest enclosure is 16 squares. If there are no enclosures in a pattern, you need to output 0 0. If two or more enclosures have the same size (and that happens to be the maximum size), you need to output that size.
EX I/P:
6 4
\//\\/
\///\/
//\\/\
\/\///
3 3
///
\//
\\\
0 0
EX O/P
2 16
0 0
Note:
/\
\/
will have 4 diamond shape squares in it. They have given a image. not able to add it here.| Report Duplicate | Flag | PURGE
Amdocs C - 0of 0 votes
Answerswhat does malloc return ?
- ashish March 25, 2012 in India for bing
what happens when you allocate memeory using malloc(sizeof(node)) in your code, where node is a pointer variable of list* node;| Report Duplicate | Flag | PURGE
Microsoft Software Engineer / Developer C - 0of 0 votes
Answersint i=10,j=20;
- gk.grover33 March 24, 2012 in India
int *p=&i;
int *q=&j;
int c=p-q;
what is the value of c and explain the output.| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersA singly linked list has integer as data in each node. Write a function to delete a node from the list given an integer as argument. (Assume all the nodes have unique integers)
- lippie March 21, 2012 in United States for Switching Softwares| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer Algorithm C Linked Lists - 0of 0 votes
AnswersGiven a Binary tree , you need to traverse and only print all nodes on given level L.
- lippie March 21, 2012 in United States for Switching Softwares| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer Algorithm C Linked Lists - 0of 0 votes
AnswersWrite a function which sets the bits in an integer when start bit position and end bit positions are passed as argument.
- lippie March 21, 2012 in United States for Switching Softwares
For eg, if I call function setbit(2,4) , it should return 14. (1110)
least significant bit on 1st position and so on..| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer Algorithm C - 0of 0 votes
AnswersWrite a function to sort the linked list given the head as parameter. Do not use extra memory. You have to sort it in place. Time complexity is secondary. (He told me that he wants to see how fast I can code with any of of the solutions)
- lippie March 21, 2012 in United States for Switching Softwares| Report Duplicate | Flag | PURGE
Cisco Systems Software Engineer / Developer Algorithm C Coding Linked Lists - 0of 0 votes
AnswersGiven a linked list of integers, delete all the nodes from the linked list which data value equals to a given value.
- Lily March 20, 2012 in United States
void delete(Node **l, int target);| Report Duplicate | Flag | PURGE
Arista Networks Software Engineer / Developer Algorithm C Linked Lists - 0of 0 votes
AnswersHow can we avoid a stack overflow ?
- pnkjtr March 20, 2012 in India
The problem is like this. Lets say I have a method A() invoked from main(). Now A() invokes B(), B() inturn invokes C() ... keep going...
so the current process stack will have limited capacity to accomodate all the activation frames that are being created dynamically when each new method is invoked.
so if this continues, at one point of time, stack will exhaust. so whats the method to handle this.
The very simple example can be:
void main (){
main();
return 0;
}
if you run this, we can see the error as run time error for stack overflow. in such scenario whats the optimal way to deal with it?| Report Duplicate | Flag | PURGE
Developer Program Engineer C