C Interview Questions
- 0of 0 votes
Answerswhat is function pointers? what is use of it ?
- Sach July 25, 2012 in India| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerwhat is pointers and why pointers are used ?
- Sach July 25, 2012 in India| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersGive the output of the following code:
- akash1600 July 24, 2012 in United States#include<iostream> using namespace std; int main() { int a=10,b=2; b=a+++a; cout<<b<<" "<<a"\n"; return 0; }
| Report Duplicate | Flag | PURGE
Microsoft Intern C - 0of 0 votes
Answerssearch an element in sorted 3D Array .(Sorted in all the 3 directions) .
- Shobhit July 20, 2012 in United States
best time complexity (less than O(n^2))| Report Duplicate | Flag | PURGE
Amazon C - 0of 0 votes
Answersfile 1:
- ninja July 18, 2012 in India
int arr[10];
file 2:
extern int *arr;
foo(){
arr[0]=10;
}
what can be the problems and in what conditions ?| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answersgiven a string . find the first unique character .
- Shobhit July 18, 2012 in United States
time complexity : O(logn) , space O(1)| Report Duplicate | Flag | PURGE
Amazon C - 0of 0 votes
AnswersHow will you return
int
and
char
from a function in C?
- bobbysanders007 July 16, 2012 in United States| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWAP to reverse the bits in integer (inplace)!!!
- deepakyadav1830 July 15, 2012 in United States
e.g i/p: 1011 o/p 1101| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWAP which print its source code as its output!!!:)
- deepakyadav1830 July 15, 2012 in United States| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersWhy ans is 2 for both
--int main() { int x = 1; x=x++/++x; printf("%d\n",x); return 0; }
======and======
int main() { int x = 1; x=++x/x++; printf("%d\n",x); return 0;
}
- niraj.nijju July 12, 2012 in United States| Report Duplicate | Flag | PURGE
C - 1of 1 vote
AnswersImplement the plusplus operator when we are getting the input as integer array = { 9,9,9,9 }.output will be {1,0,0,0,0}
- JobHunter July 11, 2012 in United States| Report Duplicate | Flag | PURGE
Google Software Engineer / Developer Algorithm Arrays C Coding Data Structures - 0of 0 votes
AnswersWrite a code in C for the following:
- jeanclaude July 09, 2012 in United States
Starting from 1, assign an alphabet to each integer, for e.g. if input is 1 then A should be the output), 2 = B ....... 26 = Z. Similarly, 27 = AA, 28 = AB..........52 = AZ. 702 = ZZ, 703 = AAA and so on. The function takes only one integer argument . for e.g ConvertToAphabet(int x). One additional consideration here is, the user is free to provide any length of integer (bigint long int etc), no restriction there.| Report Duplicate | Flag | PURGE
Microsoft Software Engineer in Test C - 0of 0 votes
AnswersExplain the output:
- kishore July 08, 2012 in United States
#include <stdio.h>
int main() {
int x = 1;
x=++x/x++;
printf("%d\n",x);
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersExplain the output :
- Shobhit July 06, 2012 in United States
#include<stdio.h>
int main()
{ double i=0;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
i+=0.1;
if(i==0.7)
printf("Equal : i=0.7\n");
i+=0.1;
if(i==0.8) printf("Equal : i=0.8\n");
else printf("Not Equal : i=0.8\n");
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answerschar *p="havfun" , *q ="havfun" ;
- Shobhit July 05, 2012 in United States
are these two pointers equal ? If yes , then explain .| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersCompare the behavior of both the programs :
- Shobhit July 05, 2012 in United States
(1) . #include<stdio.h>
int main()
{
int i,a[3];
for(i=0;i<=3;i++)
a[i]=1;
for(i=0;i<=3;i++)
printf("%d\n",a[i]);
return 0;
}
(2) . #include<stdio.h>
int main()
{
int i,a[3];
for(i=0;i<=3;i++)
a[i]=i;
for(i=0;i<=3;i++)
printf("%d\n",a[i]);
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersIs there no null character after "abcd" string in the following declaration .
- Shobhit July 05, 2012 in United States
char *p="abcd";| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersExplain the output :
- Shobhit July 05, 2012 in United States
int main()
{
struct{int a:1;
int b;
}obj;
obj.b=6;
obj.a=1;
printf("%d %d",obj.b,obj.a);
return 0;
}| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersIn the following declaration ptr is
- Shobhit July 05, 2012 in United States
far * near * huge * ptr;
1. far
2. huge
3. near
4. all of the above| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answersmain(){
- Shobhit July 03, 2012 in United States
union d{
unsigned int a:1;
unsigned int b:3;
unsigned c:2;};
union d aa;
aa.b=6;aa.c=2;aa.a=1;
printf("%d %d %d",aa.a,aa.b,aa.c);}
What does the above code output?| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answers#include<stdio.h>
- Shobhit July 03, 2012 in United States
#include<conio.h>
int main()
{
int i;
i=5;
i=++i/i++;
printf("%d",i);
getch();
}
Explain the output .| Report Duplicate | Flag | PURGE
C - 1of 1 vote
Answersint fun(char *a){
- Shobhit July 02, 2012 in United States
printf("%d\n",sizeof(a));
return 1; }
int main()
{
char a[20];
printf("%d\n",sizeof(fun(a)));
}
Explain the output.| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answersfile 1 : int a[80];
- Shobhit July 02, 2012 in United States
file 2 : extern int *a;
int main(){
a[12]=100;
printf("%d\n",a[12]); }
Both files are compiled together . It's showing runtime error .
Why not linker error ?| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answersint main()
- Shobhit July 02, 2012 in United States
{
int val,x=3,y=2,z=1,q=4;
val=(x>y?(x<z?20:10&&y>x?50:100):(y<z?40:9||x>q?30:10));
printf("%d\n",val);
}
Explain the output .| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersThe following C program segfaults of IA-64, but works fine on IA-32.
- Shobhit July 02, 2012 in United States
int main()
{
int* p;
p = (int*)malloc(sizeof(int));
*p = 10;
return 0;
}
Why does it happen so?| Report Duplicate | Flag | PURGE
C - 0of 0 votes
Answers#include<stdio.h>
- Shobhit July 02, 2012 in United States
int main()
{
int a=10;
switch(a)
{
case '1':
printf("ONE\n");
break;
case '2':
printf("TWO\n");
break;
defa1ut: // There should be an error .
printf("NONE\n");
}
return 0;
}
Check the output .. and explain why is it not showing an error ?| Report Duplicate | Flag | PURGE
C - 0of 0 votes
AnswersExplain the output
- Shobhit July 01, 2012 in United States
#include<stdio.h>
void f()
{
int a[12];
int i=0;
for(i=0;i<12;i++)
a[i]=1;
}
void g()
{
int b[12];
int i=0;
for(i=0;i<12;i++)
printf("%d\n",b[i]);
}
int main()
{
f();
g();
return 0;
}| Report Duplicate | Flag | PURGE
C