Placement papers on Data Structure - Set 2

Placement papers on Data Structure - Set 2


1. char txt [20] = "Hello world!\0";
How many bytes are allocated by the definition above?

11 bytes
12 bytes
13 bytes
20 bytes
21 bytes
View Answer / Hide Answer

ANSWER: 13 bytes




2.
#include<stdio.h>
struct game
{
int level;
int score;
struct player
{
char *name;
}g2;
}g1;
void main()
{
clrscr();
printf("%d %d %s",g1.level,g1.score,g1.g2.name);
getch();
}

What will output when you compile and run the above code?

Garbage_value garbage_value garbage_value
0 0 (null)
Run time error
Compiler error
View Answer / Hide Answer

ANSWER: 0 0 (null)




3.
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
unsigned int num;
int i;
scanf("%u", &num);
for(i=0; i<16; i++)
{
printf("%d", (num<<i & 1<<15)?1:0);
}
return 0;
}

It prints all even bits from num
It prints all odd bits from num
It prints binary equivalent num
Error
View Answer / Hide Answer

ANSWER: It prints binary equivalent num




4.
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
unsigned int num;
int i;
scanf("%u", &num);
for(i=0; i<16; i++)
{
printf("%d", (num<<i & 1<<15)?1:0);
}
return 0;
}

It prints all even bits from num
It prints all odd bits from num
It prints binary equivalent num
Error
View Answer / Hide Answer

ANSWER: It prints binary equivalent num




5.
Which of the following statements are correct about the program?
#include<stdio.h>

int main()
{
unsigned int num;
int c=0;
scanf("%u", &num);
for(;num;num>>=1)
{
if(num & 1)
c++;
}
printf("%d", c);
return 0;
}

It counts the number of bits that are ON (1) in the number num.
It counts the number of bits that are OFF (0) in the number num.
It sets all bits in the number num to 1
Error
View Answer / Hide Answer

ANSWER: It counts the number of bits that are ON (1) in the number num.




6.
Which of the following statements are correct about the program?
#include<stdio.h>
char *fun(unsigned int num, int base);

int main()
{
char *s;
s=fun(128, 2);
s=fun(128, 16);
printf("%s\n",s);
return 0;
}
char *fun(unsigned int num, int base)
{
static char buff[33];
char *ptr = &buff[sizeof(buff)-1];
*ptr = '\0';
do
{
*--ptr = "0123456789abcdef"[num %base];
num /=base;
}while(num!=0);
return ptr;
}

It converts a number to a given base.
It converts a number to its equivalent binary.
It converts a number to its equivalent hexadecimal.
It converts a number to its equivalent octal.
View Answer / Hide Answer

ANSWER: It converts a number to a given base.




7. Which one of the following is NOT a valid identifier?

__ident
auto
bigNumber
g42277
peaceful_in_space
View Answer / Hide Answer

ANSWER: auto




8. char ** array [12][12][12];
Consider array, defined above. Which one of the following definitions and initializations of p is valid?

char ** (* p) [12][12] = array;
char ***** p = array;
char * (* p) [12][12][12] = array;
const char ** p [12][12][12] = array;
char (** p) [12][12] = array;
View Answer / Hide Answer

ANSWER: char ***** p = array;




10. What does the "auto" specifier do?
It automatically initializes a variable to 0;.

It indicates that a variable's memory will automatically be preserved.
It automatically increments the variable when used.
It automatically initializes a variable to NULL.
It indicates that a variable's memory space is allocated upon entry into the block.
View Answer / Hide Answer

ANSWER: It indicates that a variable's memory will automatically be preserved.




11. How do you include a system header file called sysheader.h in a C source file?

#include <sysheader.h>
#incl "sysheader.h"
#includefile < sysheader>
#include sysheader.h
#incl < sysheader.h>
View Answer / Hide Answer

ANSWER: #incl "sysheader.h"




12. The Average case occur in linear search algorithm

When Item is somewhere in the middle of the array
When Item is not in the array at all
When Item is the last element in the array
When Item is the last element in the array or is not there at all
View Answer / Hide Answer

ANSWER: When Item is somewhere in the middle of the array




13. The complexity of the average case of an algorithm is

Much more complicated to analyze than that of worst case
Much more simpler to analyze than that of worst case
Sometimes more complicated and some other times simpler than that of worst case
None or above
View Answer / Hide Answer

ANSWER: Much more complicated to analyze than that of worst case




14. In a linked list with n nodes, the time taken to insert an element after an element pointed by some pointer is

0 (1)
0 (log n)
0 (n)
0 (n 1og n)
View Answer / Hide Answer

ANSWER: 0 (n 1og n)




15. The complexity of Binary search algorithm is

O(n)
O(log )
O(n2)
O(n log n)
View Answer / Hide Answer

ANSWER: O(n2)


Post your comment

    Discussion

  • RE: Placement papers on Data Structure - Set 2 -Sujit Gawand (06/28/19)
  • Ans of 1st is 20 bytes checked on turbo c compiler also, if we use char x[]="Hii\0"; then only its size is equa to no of characters.
  • RE: Placement papers on Data Structure - Set 2 -Aayushi (10/23/16)
  • Which is right ans

    Which is given
    OR
    Which is in discussion
  • RE: Placement papers on Data Structure - Set 2 -Abbas Ali (04/10/16)
  • 14 In a linked list with n nodes, the time taken to insert an element after an element pointed by some pointer is
    Answer is O(1)
  • RE: Placement papers on Data Structure - Set 2 -Dheeraj kumar (07/02/15)
  • 11. How do you include a system header file called sysheader.h in a C source file?
    ans:correct ans is #include
  • RE: Placement papers on Data Structure - Set 2 -Dheeraj kumar (07/02/15)
  • Q .15 the complexity of binary search algorithm is
    ans:incorrect given
    the correct ans is O(log n)