| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | Is this code legal?
int *ptr;
ptr = (int *) 0x400; | | 1 | | main()
{
printf("%d, %d", sizeof('c'), sizeof(100));
}
a. 2, 2
b. 2, 100
c. 4, 100
d. 4, 4 | HCL | 3 | | #include<stdio.h>
main()
{
const int i=4;
float j;
j = ++i;
printf("%d %f", i,++j);
} | | 1 | | void main()
{
int k=ret(sizeof(float));
printf("\n here value is %d",++k);
}
int ret(int ret)
{
ret += 2.5;
return(ret);
} | | 1 | | char *someFun1()
{
char temp[ ] = string";
return temp;
}
char *someFun2()
{
char temp[ ] = {s, t,r,i,n,g};
return temp;
}
int main()
{
puts(someFun1());
puts(someFun2());
} | | 1 | | What is the main difference between STRUCTURE and UNION? | | 6 | | Write a function to find the depth of a binary tree. | Adobe | 8 | | void main()
{
int i=10, j=2;
int *ip= &i, *jp = &j;
int k = *ip/*jp;
printf(%d,k);
} | | 1 | | How to read a directory in a C program?
| | 4 | | What is the output for the program given below
typedef enum errorType{warning, error,
exception,}error;
main()
{
error g1;
g1=1;
printf("%d",g1);
} | | 1 | | main()
{
int i=5;
printf("%d%d%d%d%d%d",i++,i--,++i,--i,i);
} | | 1 | | main( )
{
static int a[ ] = {0,1,2,3,4};
int *p[ ] = {a,a+1,a+2,a+3,a+4};
int **ptr = p;
ptr++;
printf(\n %d %d %d, ptr-p, *ptr-a, **ptr);
*ptr++;
printf(\n %d %d %d, ptr-p, *ptr-a, **ptr);
*++ptr;
printf(\n %d %d %d, ptr-p, *ptr-a, **ptr);
++*ptr;
printf(\n %d %d %d, ptr-p, *ptr-a, **ptr);
} | | 1 | | 1)
int i=5;
j=i++ + i++ + i++;
printf("%d",j);This code gives the answer 15.But if we
replace the value of the j then anser is different?why?
2)int i=5;
printf("%d",i++ + i++ + i++);
this givs 18. | Infosys | 6 | | main()
{
int i;
clrscr();
for(i=0;i<5;i++)
{
printf("%d\n", 1L << i);
}
}
a. 5, 4, 3, 2, 1
b. 0, 1, 2, 3, 4
c. 0, 1, 2, 4, 8
d. 1, 2, 4, 8, 16 | HCL | 1 | | main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("\n%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
} | | 1 | | main()
{
41printf("%p",main);
}8 | | 1 | | main()
{
int i=300;
char *ptr = &i;
*++ptr=2;
printf("%d",i);
} | | 1 | | How do you write a program which produces its own source
code as its output?
| | 7 | | In the following pgm add a stmt in the function fun such
that the address of
'a' gets stored in 'j'.
main(){
int * j;
void fun(int **);
fun(&j);
}
void fun(int **k) {
int a =0;
/* add a stmt here*/
} | | 1 | | main()
{
int i=1;
while (i<=5)
{
printf("%d",i);
if (i>2)
goto here;
i++;
}
}
fun()
{
here:
printf("PP");
} | | 1 | | | | For more C Code Interview Questions Click Here |
|