C Interview Questions
- 0of 0 votes
AnswersWhy doesn't *p in printf statement print 10.
- pop23g July 01, 2012 in United States
int main()
{
int *p,i=10;
p=&i;
printf("Enter the pointer\n");
scanf("%p",p);
printf("%u\t%d\t%u",p,*p,&i);
return 0;
}| Report Duplicate | Flag | PURGE
Software Engineer / Developer C - 0of 0 votes
Answer#include<stdio.h>
- Shobhit June 28, 2012 in United States
#if something == 0
int some=0;
#endif
int main(){
int thing = 0;
printf("%d %d\n", some ,thing);
}
Explain the output .| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answers#include<stdio.h>
- Shobhit June 28, 2012 in United States
#include<string.h>
void f(int **c){
printf("%d",c[0][0]);
}
int main(){
int c[2][2]={1,2,3,4};
f(c);
return 0;
}
Explain the output and also remove the error if any .| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswerWrite a C program which counts 1, 2, 3... and so on, every second. On pressing Ctrl+C, the timer should pause and then pressing Ctrl+Z should resume the timer
- Shobhit June 28, 2012 in United States| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerswrite a C program which generates random numbers between 1-100 (inclusive) on mouse movements.
- Shobhit June 28, 2012 in United States| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersQuestion 4: Maze Problem (Bonus)
- godzilla June 23, 2012 in Canada
Starting point is m[0][0], need to find a path go to m[9][9]. 0 means OK, 1 means cannot go there, boundary is 0 and 9, cannot go beyond boundary. Each step can be made horizontally or vertically for one more grid (diagonal
jump is not allowed).
Your program should print a series of grid coordinates that start from m[0][0]
and go to m[9][9]
Hint: No need to find the shortest path, only need to find one path that gets
you to desitination.| Report Duplicate | Flag | PURGE
Fortinet Software Engineer / Developer C - 0of 0 votes
Answer3 hour coding test.
- godzilla June 23, 2012 in Canada
Question 1: Delete an item in a linked list| Report Duplicate | Flag | PURGE
Fortinet Software Engineer / Developer C - 0of 0 votes
AnswersGive output for the following code
#include<stdio.h> void main() { int i = 5; printf("%d\n",i++ + ++i); printf("%d\n",i++ + ++i + i++ + i++); printf("%d\n",++i + i++ + ++i + i++); }
Please give the output with os and compiler u used with proper explanation. Getting unexpected answers..... help !!!
- saj1919 June 21, 2012 in United States
This is old question posed by senior student.| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer in Test C - 0of 0 votes
AnswersHow will you find out size of a variable without using sizeof ();
- Avi June 20, 2012 in India| Report Duplicate | Flag | PURGE
Infosys Software Engineer / Developer C - 0of 0 votes
Answerswhat is the output
- manishvaidya June 15, 2012 in United States
main(){
int x=10,y;
y=++x++;
printf("%d%d",x,y);
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWhy the output of following code is always 0.000000
- pnyaswant June 14, 2012 in India
main()
{
float a;
scanf("%f",&a);
printf("%f",(int)a);
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerswhat is the o/p of following along with justifying logic ?
- jainabhishek.inc June 13, 2012 in United States#include<stdio.h> main() { int i=0; prrintf("%%%%"); }
| Report Duplicate | Flag | PURGE
Accenture Applications Developer C - 0of 0 votes
AnswersExplain the output :
- Shobhit June 12, 2012 in United States
#include<stdio.h>
#define power(a) #a
int main()
{
printf("%d",*power(432));
getch();
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerswrite atoi() function
- Itcecsa June 10, 2012 in United States| Report Duplicate | Flag | PURGE
Bloomberg LP Financial Software Developer C - 0of 0 votes
AnswersWhat would be the output for the following code fragment?
- CC++ June 06, 2012 in United States
main()
{
int i=300;
char *ptr = &i;
*++ptr=2;
printf("%d",i);
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWhat would be the output for the following code fragment?
- CC++ June 06, 2012 in United States
void foo(int b[][3] );
main()
{
int a [3][3]= { { 1,2,3} , { 4,5,6},{7,8,9}};
foo(a);
printf("%d" , a[2][1]);
}
void foo( int b[][3])
{
++ b;
b[1][1] =9;
}
(a) 8
(b) 9
(c) 7
(d) None of the above| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersDifferentiate the above declarations.
- CC++ June 06, 2012 in United States
1. const char *a;
2. char* const a;
3. char const *a;
For each of the above, which operation below is legal and which is not?
*a='F'
a ="Hi"| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWhat does the following represent?
- CC++ June 06, 2012 in United States
void (*abc(int, void (*def)()))();| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWhat does the following do:
- CC++ June 06, 2012 in United States
void afunction(int *x)
{
x=new int;
*x=12;
}
int main()
{
int v=10;
afunction(&v);
cout<<v;
}
a) Outputs 12
b) Outputs 10
c) Outputs the address of v| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWhat is the output of the following procedure
- gdrocell June 01, 2012 in United States for SIGOV
{
void foo() {
int* a = 0;
char* b = NULL;
printf("%x %x", a, b);
printf("%x %x", *a, b);
printf("%x %x");
}
}| Report Duplicate | Flag | PURGE
Raytheon Reverse Engineering and System Developer C - 0of 0 votes
AnswersExpand the following fragment of C code to make it more understandable
- gdrocell June 01, 2012 in United States for SIGOV
{char* c = *a ? *++*a : *++*b;}| Report Duplicate | Flag | PURGE
Raytheon Reverse Engineering and System Developer C - 0of 0 votes
AnswersWhat is conditional compilation ? Please explain it with an example.
- Pranay Singhania May 29, 2012 in India| Report Duplicate | Flag | PURGE
C - 1of 1 vote
AnswersGiven two numbers "a" and "b" and an average formula (a+b)/2. Find one condition where it wont work. Also, give solution to it
- dvyas May 16, 2012 in United States| Report Duplicate | Flag | PURGE
NVIDIA Software Engineer / Developer Bit Manipulation C - 3of 3 votes
AnswersQ1.- Written exam (Amazon, Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a singly link list and a number 'K', swap the Kth node from the start with the Kth node from the last. Check all the edge cases.
Sample Input: 1->2->3->4->5->6->7->8 and K = 3
Sample Output : 1->2->6->4->5->3->7->8
Sample Input: 1->2->3->4->5->6->7->8 and K = 10
Sample Output: print error "LIST IS OF LESSER SIZE".| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm C C# C++ Coding Data Structures Java Linked Lists - 0of 0 votes
AnswersQ2. F2F Round-1, Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given an array of integers having the property that first that array is strictly increasing then it is strictly decreasing, You have to search for a given number.
Constraint: Minimize the complexity| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays C C# C++ Coding Data Structures Java - 0of 0 votes
AnswersQ1. F2F Round 1 Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given a character array as input. Array contains only three types of characters 'R', 'G' and 'B'. Sort the array such that all 'R's comes before 'G's and all 'G's comes before 'B's.
Constraint :- No extra space allowed(except O(1) space like variables) and minimize the time complexity.
You can only traverse the array once.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays C C# C++ Coding Data Structures Java Sorting - 0of 0 votes
AnswersQ4. Written Exam Amazon(Bangalore)
- Nitin Gupta May 12, 2012 in India
Given an array of integers A[1....n-1] where 'N' is the length of array A[ ]. Construct an array B such that B[i] = min(A[i], A[i+1], ......., A[i-K+1]), where K will be given.
Array B will have N-K+1 elements.
Constraint: Extra space allowed O(K) and time complexity allowed O(N.K) or lower.| Report Duplicate | Flag | PURGE
Amazon Software Engineer / Developer Algorithm Arrays C C# C++ Coding Data Structures Java Sorting