| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | 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 | | print numbers till we want without using loops or condition
statements like specifically(for,do while, while swiches,
if etc)!
| | 7 | | void main()
{
unsigned giveit=-1;
int gotit;
printf("%u ",++giveit);
printf("%u \n",gotit=--giveit);
} | | 1 | | main()
{
int i = 0xff ;
printf("\n%d", i<<2);
}
a. 4
b. 512
c. 1020
d. 1024 | HCL | 1 | | void main()
{
if(~0 == (unsigned int)-1)
printf(“You can answer this if you know how values are
represented in memory”);
} | | 1 | | What is the output of the program given below
main()
{
signed char i=0;
for(;i>=0;i++) ;
printf("%d\n",i);
} | | 1 | | char inputString[100] = {0};
To get string input from the keyboard which one of the
following is better?
1) gets(inputString)
2) fgets(inputString, sizeof(inputString), fp) | | 1 | | #include<stdio.h>
main()
{
struct xx
{
int x=3;
char name[]="hello";
};
struct xx *s;
printf("%d",s->x);
printf("%s",s->name);
} | | 1 | | #if something == 0
int some=0;
#endif
main()
{
int thing = 0;
printf("%d %d\n", some ,thing);
} | | 1 | | main()
{
char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcpy(a,b));
}
a. “Hello”
b. “Hello World”
c. “HelloWorld”
d. None of the above | HCL | 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 | | main()
{
signed int bit=512, i=5;
for(;i;i--)
{
printf("%d\n", bit >> (i - (i -1)));
}
}
a. 512, 256, 0, 0, 0
b. 256, 256, 0, 0, 0
c. 512, 512, 512, 512, 512
d. 256, 256, 256, 256, 256 | HCL | 1 | | enum colors {BLACK,BLUE,GREEN}
main()
{
printf("%d..%d..%d",BLACK,BLUE,GREEN);
return(1);
} | | 1 | | main()
{
char *p = “ayqm”;
printf(“%c”,++*(p++));
} | TCS | 2 | | How to access command-line arguments? | | 4 | | write a program in c to merge two array | | 1 | | main(){
unsigned int i;
for(i=1;i>-2;i--)
printf("c aptitude");
} | | 1 | | #include<stdio.h>
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
} | | 1 | | main()
{
char a[4]="HELL";
printf("%s",a);
} | Wipro | 1 | | how to check whether a linked list is circular. | | 3 | | | | For more C Code Interview Questions Click Here |
|