Communiquez avec les autres et partagez vos connaissances professionnelles

Inscrivez-vous ou connectez-vous pour rejoindre votre communauté professionnelle.

Suivre

What will be the correct output for the given code snippet?

  1. class maths
  2. {
  3. int fact(int n)
  4. {
  5. int result;
  6. if (n == 1)
  7. return 1;
  8. result = fact(n - 1) * n;
  9. return result;
  10. }
  11. }
  12. class Output
  13. {
  14. static void main(String args[])
  15. {
  16. maths obj = new maths() ;
  17. Console.WriteLine(obj.fact(4)*(3));
  18. }
  19. }

a)b)c)d)

user-image
Question ajoutée par Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb
Date de publication: 2016/10/21
Shilpa Kotian
par Shilpa Kotian , Software engineer , Reliable sol

72 is the answer

72 =fact(4)*3

fact(4) =fact(3) *4

fact(3)=fact(2)*3

fact(2)=fact(1)*2

fact(1)= 1 because if n==1 then return 1

More Questions Like This

Avez-vous besoin d'aide pour créer un CV ayant les mots-clés recherchés par les employeurs?