3i Infotech Papers: Sample Questions 177 - 178 of 1245

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

Question number: 177

» Languages » C & C Plus Plus

Essay Question▾

Describe in Detail

Find the output of the following program

  1. const int size = 5;
  2. void print(int *ptr)
  3. {
  4.     cout<<ptr[0];
  5. }
  6. void print(int ptr[size])
  7. cout<<ptr[0];
  8. }
  9. void main()
  10. {
  11.     int a[size] = {1,2,3,4,5};
  12.     int *b = new int(size);
  13.     print(a);
  14.     print(b);
  15. }

Explanation

  • In the program

Table showing the program

Table showing the program

const int size = 5;

  • Defines the constant integer variable size = 5

  1. void print(int *ptr)
  2. {
  3.     cout < < ptr[0];
  4. }
  • Defines the void print () function.

  • Print () function defines the int * ptr arguments

  1. void print(int ptr[size])
  2. {
  3.     cout < < ptr[0];
  4. }
  • Defines the void print () function.

  • Print () function defines the int ptr [size] arguments

  1. void main()
  2. {
  3.     int a[size] = {1,2,3,4,5};
  4.     int *b = new int(size);
  5.     print(a); print(b);
  6. }
  • Main function defines the integer array a [size] = {1,2, 3,4, 5};

  • Defines the integer pointer b

  • But arrays cannot be passed to functions, only pointers (for arrays, base addresses) can be passed.

  • So the arguments int * ptr and int ptr [size] have no difference as function arguments.

  • In other words, both the functions have the same signature and so cannot be overloaded.

Question number: 178

» Database » MySQL

Essay Question▾

Describe in Detail

Why does the following command give a compilation error?

DROP TABLE &TABLE_NAME.

Explanation

  • Variable name starts with an alphabet.

  • The table name cannot starts with an ‘&’ symbol.

DROP TABLE:

  • Drop table statement is used to drop an existing table in database.

Syntax:

DROP TABLE table_name;

Parameters:

table_name

  • Table name is removed from the database.