Accenture Placement: Sample Questions 3 - 5 of 9

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 3

Describe in Detail Essay▾

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

Explanation

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

extern int i;

Table Shows the Program
Extern int iDeclare the extern integer i
i = 20Integer 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’

Question 4

Describe in Detail Essay▾

  1. main()
  2. {
  3. int i=3;
  4. switch (i)
  5. {
  6. default:printf(“zero”);
  7. case 1:printf(“one”);
  8. break;
  9. case 2:printf ( “two” );
  10. break;
  11. case 3:printf ( “three” );
  12. break;
  13. }
  14. }
Edit

Explanation

Given i = 3

Table Shows the Program
Int i = 3Given integer variable i = 3
  1. switch (i)
  2. {
  3. default:Printf(“zero”);
  4. case 1:Printf(“one”);
  5. break;
  6. case 2:Printf ( “two” );
  7. break;
  8. case 3:Printf ( “three” );
  9. break;
  10. }
In this switch condition case 3 (i = 3) is selected

As there is a break statement after it, it comes out of the switch

So, answer is three.

Question 5

Write in Short Short Answer▾

  1. Void main ()
  2. {
  3. int const ⚹=5;
  4. printf(“%d”++(⚹p));
  5. }
Edit

Explanation

  • In a program
    Table Shows the Program
    int const ⚹ p = 5;Pointer to constant integer
    printf ( “% d” ++ (⚹ p) ) ;We tried to change constant integer value
  • But constant value can՚t change
  • So, the answer is Compiler error: Cannot modify a constant value.