Languages-C & C Plus Plus [3i Infotech Placement]: Sample Questions 113 - 114 of 354

Glide to success with Doorsteptutor material for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 113

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is a protocol class?

Explanation

An abstract class is a protocol class:

  • Which neither contains nor inherits from classes that contain member data, non-virtual functions, or private (or protected) members of any kind.
  • With a non-inline virtual destructor defined with an empty implementation,
  • In which all member functions other than the destructor including inherited functions, are declared pure virtual functions and left undefined.
Given the Image is Instead of “Protocol” Think “Base Class with Pure Virtual Functions.”

Question 114

C & C Plus Plus
Edit

Describe in Detail

Essay▾

What is the output of the following program?

  1. main (intargc, char ⚹⚹ argv)
  2. {
  3.     printf (“enterthecharacter” );
  4.     getchar();
  5.     sum (argv[1], argv[2]);
  6. }
  7. sum(num1, num2)
  8. intnum1, num2;
  9. {
  10.     returnnum1 +num2;
  11. }

Explanation

In the program

Table Shows the Program
main (int argc, char ⚹⚹ argv)Define the main function with variable argc and character pointer to pointer argv
printf ( “enter the character” ) ;Print “enter the character”
getchar () ;getchar () gets a character from stdin.

This is equivalent to getc with stdin as its argument.

sum (argv [1] , argv [2] ) ;argv [1] & argv [2] are string. They are passed to the function sum without converting it to integer values.

So, the compiler errors are generated.

Developed by: