Part1 – Interview Questions - Interview Questions
- nonportablepointer conversion
- can not modify constant object[ANS]
- 6
- a & b
- 0
- constant out of range[ANS]
- irreducible expression
- a & c
- man
- null pointerassignment
- mmm aaa nnn[ANS]
- non of these
- condition is true
- condition is false[ANS]
- no output
- misplaced else
- illegal structure operation error[ANS]
- e1 and e2 are same
- e1 and e2 are different
- nonofthese
- he_who_must_not_be_named
- VOLDMORT[ANS]
- compile error
- voldmort
- ffff
- no effect
- 0xffff
- a& b [ANS]
- -4 3 0 0
- -2 3 0 0
- -2 3 0 1 [ANS]
- -5 3 0 1
- XAM is printed
- exam is printed
- Compiler Error
- Nothing is printed[ANS]
- Address of the array
- Values of the first elements of the array
- Address of the first element of the array[ANS]
- Number of element of the array
- k k
- Don`t walk in front of me
- I may not follow
- K[ANS]
- 444
- 000
- 333[ANS]
- 433
- program will not compile[ANS]
- 10
- god only knows
- address of I
- 5
- 6
- 10 [Ans] Corrected by buddy by running the program
- 11
- 12
- unalloc()
- dropmem()
- dealloc()
- release()
- free() [Ans]
- ptr = ptr + sizeof(myStruct); [Ans]
- ++(int*)ptr;
- ptr = ptr + sizeof(myArray);
- increment(ptr);
- ptr = ptr + sizeof(ptr);
- y = HELLO
- y = ELLO
- y = LLO
- y = LO [Ans]
- x = O
- It will work correctly since the for loop covers the entire list.
- It may fail since each node “nPtr” is freed before its next address can be accessed.
- In the for loop, the assignment “nPtr=nPtr->next” should be changed to “nPtr=nPtr.next”.
- This is invalid syntax for freeing memory.
- The loop will never end.
- fileread()
- getline()
- readfile()
- fread()
- gets()
- printf(”\”My salary was increased by 15/%\!\”\n”);
- printf(”My salary was increased by 15%!\n”);
- printf(”My salary was increased by 15′%’!\n”);
- printf(”\”My salary was increased by 15%%!\”\n”);[Ans]
- printf(”\”My salary was increased by 15′%’!\”\n”);
- Both can occur multiple times, but a declaration must occur first.
- There is no difference between them.
- A definition occurs once, but a declaration may occur many times.
- A declaration occurs once, but a definition may occur many times. [Ans]
- Both can occur multiple times, but a definition must occur first.
- 3
- 5
- 7
- 9
- 11[Ans]
- 12,10,11,13
- 22,10,11,13
- 22,11,11,11
- 12,11,11,11
- 22,13,13,13[Ans]
- -3
- 0
- 4[Ans]
- 4 + sizeof( int )
- 4 * sizeof( int
- 1, 2, 3, 4, 5, 5,
- 4, 3, 2, 1, 0, 0,
- 5, 4, 3, 2, 1, 0,
- 0, 0, 1, 2, 3, 4, [Ans]
- 0, 1, 2, 3, 4, 5,
- 1
- 6
- 8
- 14 [Ans]
- 15
- MAX_NUM is an integer variable.
- MAX_NUM is a linker constant.
- MAX_NUM is a precompiler constant.
- MAX_NUM is a preprocessor macro. [Ans]
- MAX_NUM is an integer constant.
- setbuf( stdout, FALSE );
- setvbuf( stdout, NULL );
- setbuf( stdout, NULL );
- setvbuf( stdout, _IONBF );
- setbuf( stdout, _IONBF );
- FILE *f = fwrite( “test.bin”, “b” );
- FILE *f = fopenb( “test.bin”, “w” );
- FILE *f = fopen( “test.bin”, “wb” );
- FILE *f = fwriteb( “test.bin” );
- FILE *f = fopen( “test.bin”, “bw” );
- memcpy()
- memset()
- strncpy()
- strcpy()
- memmove()[Ans]
- 22
- 26[Ans]
- 46
- 50
- 70
- If the arguments to memcpy() refer to overlapping regions, the destination buffer will be subject to memory corruption.
- array_dup() declares its first parameter to be a pointer, when the actual argument will be an array.
- The memory obtained from alloca() is not valid in the context of the caller. Moreover, alloca() is nonstandard.
- size_t is not a Standard C defined type, and may not be known to the compiler.
- The definition of array_dup() is unusual. Functions cannot be defined using this syntax.
- Yes; it can be referenced through the register specifier.
- No; it would have to have been initially declared as a static variable.
- No; it would need to have been initially declared using the global keyword.[Ans]
- Yes; it can be referenced through the publish specifier.
- Yes; it can be referenced through the extern specifier.
- t = clock();[Ans]
- time( &t );
- t = ctime();
- t = localtime();
- None of the above
- The system stack[Ans]
- The data segment
- The processor’s registers
- The text segment
- The heap
- Machine
- Procedural[Ans]
- Assembly
- Object-oriented
- Strictly-typed
- 1
- 2
- 3
- 4
- 5 [Ans] 00,10,01,11,12
- x=0
- x=1
- x=3
- x=4[Ans]
- x=5
- 1
- 2[Ans]
- 3
- 4
- 5
- fg [Ans]because string
- efg
- defg
- cdefg
- None of the above
What is output of following program when we compile and run it?
void main()
{
int const * p=5;
printf("%d",++(*p));
}
What is output of following
void main()
{
char ch;
for(ch=0;ch<=127;ch )
printf("%c %d \n", ch, ch);
}
What is output of following?
Void main()
{
char s[ ]="man";
int i;
for(i=0;s[ i ];i++)
printf("%c%c%c%c",s[ i ],*(s+i),*(i+s),i[s]);
}
What is the output of the following program?
void main()
{
float me = 1.1;
double you = 1.1;
if(me==you)
printf("condition is true");
else
printf("condition is false");
}
What is the output of the following program?
Void main() {
struct emp {
char name[20];
int empno;
};
struct emp e1 = {"helloworld", 1311};
struct emp e2 = e1;
if (e1==e2)
printf ("e1 and e2 are same");
else
printf ("e1 and e2 are different");
}
What is the output of the following program?
# define VOLDEMORT he_who_must_not_be_named
Void main() {
printf ("VOLDEMORT");
}
What is the output of the following program?
Void main() {
unsigned int x = 0xffff;
~x;
printf ("%x", x);
}
What is the output of the following program?
Void main()
{
int a = -3, b = 2, c= 0, d;
d = ++a && ++b || ++c;
printf ("a = %d, b = %d, c = %d, d = %d", a, b, c, d);
}
What is the output?
void main()
{
int a=10,b=20;
char x=1,y=0;
if(a,b,x,y)
{
printf("EXAM");
}
}
Array passed as an argument to a function is interpreted as
What is the output of this program?
Void main()
{
char thought[2][30]={"Don`t walk in front of me..","I am not follow"};
printf("%c%c",*(thought[0]+9),*(*(thought+0)+5));
}
What is the output of the below program ?
#include
void main()
{
int I=3,*j,**k;
j=&I;
k=&j;
printf("%d%d%d",*j,**k,*(*k));
}
What is the output of this program?
Void main()
{
struct
{
int i;
}xyz;
(*xyz)->i=10;
printf("%d",xyz.i);
}
int z,x=5,y=-10,a=4,b=2;
z = x++ – –y * b / a;
What number will z in the sample above contain?
With every use of a memory allocation function, what function should be used to release allocated memory which is no longer needed?
void *ptr;myStruct myArray[10];ptr = myArray;
Which of the following is the correct way to increment the variable “ptr”?
What will print when the sample below is executed?
char* myFunc (char *ptr){
ptr += 3;
return (ptr);
}
void main()
{
char *x, *y;
x = "HELLO";
y = myFunc (x);
printf ("y = %s \n", y);
return 0;
}
The sample below releases memory from a linked list. Which of the choices below accurately describes how it will work?
struct node *nPtr, *sPtr; pointers for a linked list.
for (nPtr=sPtr; nPtr; nPtr=nPtr->next)
{
free(nPtr);
}
What function will read a specified number of elements from a file?
“My salary was increased by 15%!”
Select the statement which will EXACTLY reproduce the line of text above.
What is a difference between a declaration and a definition of a variable?
int testarray[3][2][2] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
What value does testarray[2][1][0] in the sample above contain?
What will be the output when following is executed
int a=10,b;
b=a++ + ++a;
printf("%d,%d,%d,%d",b,a++,a,++a);
What does y in the sample below equal?
int x[] = { 1, 4, 8, 5, 1, 4 };
int *ptr, y;
ptr = x + 4;
y = ptr - x;
What will the below sample produce when executed?
void myFunc (int x)
{
if (x > 0)
myFunc(--x);
printf("%d, ", x);
}
int main()
{
myFunc(5);
return 0;
}
11 ^ 5
What does the operation shown above produce?
#define MAX_NUM 15
Referring to the sample above, what is MAX_NUM?
Which one of the following will turn off buffering for stdout?
What is a proper method of opening a file for writing as binary file?
Which one of the following functions is the correct choice for moving blocks of binary data that are of arbitrary size and position in memory?
int x = 2 * 3 + 4 * 5;
What value will x contain in the sample above?
The function array_dup(), defined below, contains an error. Which one of the following correctly analyzes it?
void * array_dup (a, number, size)
const void * a;
size_t number;
size_t size;
{
void * clone;
size_t bytes;
assert(a != NULL);
bytes = number * size;
clone = alloca(bytes);
if (!clone)
return clone;
memcpy(clone, a, bytes);
return clone;
}
int var1;
If a variable has been declared with file scope, as above, can it safely be accessed globally from another file?
time_t t;
Which one of the following statements will properly initialize the variable t with the current time from the sample above?
Which one of the following provides conceptual support for function calls?
C is which kind of language?
What is the value of myArray[1][2]; in the sample below?
int i,j;
int ctr = 0;
int myArray[2][3];
for (i=0; i<3; i++)
for (j=0; j<2; j++)
{
myArray[j][i] = ctr;
++ctr;
}
What will be printed when the sample below is executed?
int x = 0;
for (x=1; x<4; x++);
printf("x=%d\n", x);
What value will x contain when the sample below is executed?
int x = 3;
if( x == 2 );
x = 0;
if( x == 3 )
x++;
else x += 2;
What string does ptr point to in the sample below?
char *ptr;
char myString[] = "abcdefg";
ptr = myString;
ptr += 5;