| Other C Code Interview Questions |
| | | Question | Asked @ | Answers | | | | char *someFun()
{
char *temp = “string constant";
return temp;
}
int main()
{
puts(someFun());
} | | 1 | | main()
{
int i=5;
printf(“%d”,i=++i ==6);
} | | 1 | | How to swap two variables, without using third variable ? | HCL | 47 | | main()
{
register int a=2;
printf("Address of a = %d",&a);
printf("Value of a = %d",a);
} | | 1 | | int swap(int *a,int *b)
{
*a=*a+*b;*b=*a-*b;*a=*a-*b;
}
main()
{
int x=10,y=20;
swap(&x,&y);
printf("x= %d y = %d\n",x,y);
} | | 1 | | What is the main difference between STRUCTURE and UNION? | | 6 | | main()
{
int i, j;
scanf("%d %d"+scanf("%d %d", &i, &j));
printf("%d %d", i, j);
}
a. Runtime error.
b. 0, 0
c. Compile error
d. the first two values entered by the user | HCL | 1 | | main()
{
char not;
not=!2;
printf("%d",not);
} | | 1 | | void main()
{
char a[]="12345\0";
int i=strlen(a);
printf("here in 3 %d\n",++i);
} | | 1 | | main()
{
char *a = "Hello ";
char *b = "World";
clrscr();
printf("%s", strcat(a,b));
}
a. Hello
b. Hello World
c. HelloWorld
d. None of the above | HCL | 1 | | main()
{
int i=-1;
+i;
printf("i = %d, +i = %d \n",i,+i);
} | | 1 | | main()
{
int x=5;
clrscr();
for(;x<= 0;x--)
{
printf("x=%d ", x--);
}
}
a. 5, 3, 1
b. 5, 2, 1,
c. 5, 3, 1, -1, 3
d. –3, -1, 1, 3, 5 | HCL | 1 | | main()
{
int c[ ]={2.8,3.4,4,6.7,5};
int j,*p=c,*q=c;
for(j=0;j<5;j++) {
printf(" %d ",*c);
++q; }
for(j=0;j<5;j++){
printf(" %d ",*p);
++p; }
} | | 1 | | Program to find the largest sum of contiguous integers in
the array. O(n) | | 7 | | #include<stdio.h>
main()
{
struct xx
{
int x;
struct yy
{
char s;
struct xx *p;
};
struct yy *q;
};
} | | 1 | | main()
{
char string[]="Hello World";
display(string);
}
void display(char *string)
{
printf("%s",string);
} | | 1 | | #include<stdio.h>
main()
{
char s[]={'a','b','c','\n','c','\0'};
char *p,*str,*str1;
p=&s[3];
str=p;
str1=s;
printf("%d",++*p + ++*str1-32);
} | | 1 | | To Write a C program to remove the repeated characters in
the entered expression or in entered characters(i.e)
removing duplicates. | Synergy | 2 | | main()
{
char *p;
p="%d\n";
p++;
p++;
printf(p-2,300);
} | | 1 | | #define clrscr() 100
main()
{
clrscr();
printf("%d\n",clrscr());
} | | 1 | | | | For more C Code Interview Questions Click Here |
|