Placement papers on Data Structure - Set 1

Placement papers on Data Structure - Set 1


1.
main()
{
int i=_l_abc(10);
printf("%d\n",--i);
}
int _l_abc(int i)
{
return(i++);
}

10
11
9
8
View Answer / Hide Answer

ANSWER: 9




2.
main()
{
char *p;
int *q;
long *r;
p=q=r=0;
p++;
q++;
r++;
printf("%p...%p...%p",p,q,r);
}

Compliation Error
0001...0002...0004
0000002…000004…0000003
Runtime Error
View Answer / Hide Answer

ANSWER: 0001...0002...0004




3.
main()
{
char *p;
p="Hello";
printf("%c\n",*&*p);
}

Address Of p
Hello
H
None
View Answer / Hide Answer

ANSWER: H




4. Which of the following statements should be used to obtain a remainder after dividing 3.14 by 2.1 ?

rem = 3.14 % 2.1;
rem = modf(3.14, 2.1);
rem = fmod(3.14, 2.1);
Remainder cannot be obtain in floating point division
View Answer / Hide Answer

ANSWER: rem = fmod(3.14, 2.1);




5. What will be the output of the following arithmetic expression ?
5+3*2%10-8*6

-37
-42
-32
-28
View Answer / Hide Answer

ANSWER: -37




6. What will be the output of the following statement?
int a=10; printf("%d &i",a,10);

error
10
10 10
none of these
View Answer / Hide Answer

ANSWER: none of these




7. What will be the output of the following statement?
printf("%X%x%ci%x",11,10,'s',12);

error
basc
Bas94c
none of these
View Answer / Hide Answer

ANSWER: basc




8. What will be the output of the following statement?
printf( 3 + "goodbye");

goodbye
odbye
Error
dbye
View Answer / Hide Answer

ANSWER: dbye




9.
#include
void func()
{
int x = 0;
static int y = 0;
x++; y++;
printf( "%d -- %d ", x, y );
}

int main()
{
func();
func();
return 0;
}

What will the code above print when it is executed?

1 -- 1 1 -- 1
1 -- 1 2 -- 1
1 -- 1 2 -- 2
1 -- 1 1 – 2
View Answer / Hide Answer

ANSWER: 1 -- 1 1 – 2




10.
long factorial (long x)
{
????
return x * factorial(x - 1);
}

With what do you replace the ???? to make the function shown above return the correct answer?

if (x == 0) return 0;
return 1;
if (x >= 2) return 2;
if (x <= 1) return 1;
View Answer / Hide Answer

ANSWER: if (x <= 1) return 1;




11.
int y[4] = {6, 7, 8, 9};
int *ptr = y + 2; printf("%d\n", ptr[ 1 ] );

What is printed when the sample code above is executed?

6
7
8
9
View Answer / Hide Answer

ANSWER: 9




12.
#include<stdio.h>
struct student
{
int roll;
int cgpa;
int sgpa[8];
};
void main()
{
struct student s={12,8,7,2,5,9};
int *ptr;
ptr=(int *)&s;
clrscr();
printf("%d",*(ptr+3));
getch();
}
What will output when you compile and run the above code?

8
7
2
Compiler error
View Answer / Hide Answer

ANSWER: 2




13. Which one of the following printf() format specifiers indicates to print a double value in decimal notation, left aligned in a 30-character field, to four (4) digits of precision?

%-30.4e
%4.30e
%-4.30f
%-30.4f
%#30.4f
View Answer / Hide Answer

ANSWER: %#30.4f




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

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

10 200 anil
200 10 anil
10 200 null
Compiler error
View Answer / Hide Answer

ANSWER: Compiler error




15.
penny = one
nickel = five
dime = ten
quarter = twenty-five
How is enum used to define the values of the American coins listed above?

enum coin {(penny,1), (nickel,5), (dime,10), (quarter,25)};
enum coin ({penny,1}, {nickel,5}, {dime,10}, {quarter,25});
enum coin {penny=1,nickel=5,dime=10,quarter=25};
enum coin (penny=1,nickel=5,dime=10,quarter=25);
enum coin {penny, nickel, dime, quarter} (1, 5, 10, 25);
View Answer / Hide Answer

ANSWER: enum coin (penny=1,nickel=5,dime=10,quarter=25);



Post your comment

    Discussion

  • RE: Placement papers on Data Structure - Set 1 -roopa (02/24/20)
  • plz...check that,answer for 7 qtn is wrong

    Basic, is may be correct answer
  • RE: Placement papers on Data Structure - Set 1 -Dheeraj kumar (07/02/15)
  • in Q.1 is function name work or not _|_abc(int i) work ???
  • RE: Placement papers on Data Structure - Set 1 -Deepak Lulla (06/27/15)
  • Please do provide the explanations also....