Accenture Papers: Sample Questions 1 - 3 of 9

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 1

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

  1. main()
  2. {
  3.     Float me =1.1;
  4.     Double you=1.1;
  5.     If (me==you)
  6.     Printf (“I Love U”);
  7.     else
  8.     printf (“ I hate U”);
  9. }

Explanation

Table shows the program

Table shows the program

float me = 1.1

It defines float value

double you = 1.1

It defines double value

if (me==you)

Condition would be true if float and double values are equal.

  • For floating point numbers (float, double, long double) the values cannot be predicted exactly.

  • Float take 4 bytes

  • Double takes 8 bytes

  • Float value and double values are not same.

  • So, apply the else condition and print I hate U

Question number: 2

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

  1. main ()
  2. {
  3.     int i=-1j= -1k=0l=2m;
  4.     m=i++ &&j++ &&k++|l++;
  5.     printf(“%d%d%d%d%dI , jk ,l ,m);
  6. }

Explanation

  • We, are know that Logical operators always give a result of 1 or 0.

  • And also the logical AND (&&) operator has higher priority over the logical OR (| ).

  • So, Expression i++ &&j++&& k++ is executed first.

    So, result of this expression is 0 (-1 && -1 && 0 = 0)

  • So, the increment in i=-1

    i = 0

    Increment in j=-1

    j = 0

    Increment in k = 0

    k = 1

    Increment in l = 2

    l = 3

  • OR operator always gives 1 except for 0|0’ combination-for which it gives 0.

    • The result of this expression is 0 (-1 && -1 && 0 = 0)

  • So, the value of m is 1

  • So, print 0 0 1 3 1

Question number: 3

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

  1. Main ()
  2. {
  3.     extern int i;
  4.     i=20;
  5.     printf(“%d” i);
  6. }

Explanation

Extern is a key word in C that indicates the scope of a variable or function.

extern int i;

Table shows the program

Table shows the program

Extern int i

Declare the extern integer i

i = 20

Integer value is 20

Printf (“%d” i)

i is available in any other program with memory space allocated for it.

During linking the linker searches for the definition of i.

So, it is not found the linker flags an error.

So generate Linker Error: Undefined symbol ‘_i’