Languages-C & C Plus Plus [TCS Placement]: Sample Questions 107 - 108 of 119

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 107

C & C Plus Plus

Describe in Detail


Which function in C can be used to append a string to another string?


  • The strcat () function- takes two parameters, the source string and the string value to be appended to the source string.
  • A copy of the second string is tacked onto the end of the first, and this combined version becomes the new first string.
  • The second string is not altered.
  • It returns the value in its first argument.
  • Example:
  1. #include<stdio.h>
  2. #include<string.h>
  3. intmain()
  4. {
  5.     charsrc[50], dest[50];
  6.     strcpy(src, “ Goenka”);
  7.     strcpy(dest, “Kartik”);
  8.     strcat(dest,src);
  9.     printf(“Myname :%s ”,dest);
  10.     return0;
  11. }


My name: Kartik Goenka

Question 108

C & C Plus Plus



Which of the following type of class allows only one object of it to be created?


Choice (4)


Friend Class


Virtual Class


Abstract Class


Singleton Class




  • Singleton pattern is a software design pattern that restricts the instantiation of a class to one object.
  • C ++ Singleton class using inheritance: In this example the base class enforces a singleton pattern.
  • Note that the function calls are static calls to their global names using the scope resolution operator.
  • The functions create () and instance () are defined as static functions in the class definitions.
  • The concept is sometimes generalized to systems that operate more efficiently when only one object exists, or that restrict the instantiation to a certain number of objects.
Given the Image is Define the Singleton Class in C ++

Developed by: