I need to add security questions while user creating his account in Drupal 8. I need to use those security questions to retrieve his password, when user forgets his password.
Any suggestions ?
Well at this time you have 2 modules but only for Drupal 7:
Security Questions provides administrator configurable challenge questions for use during the log in and password reset processes. Think of it like most bank website logins.
The password_reset module allows for passwords to be reset without involving e-mail addresses through the use of security questions.
There is not a 8.x branch at this time, so your best option is study the code and migrate one of them.