ابدأ بالتواصل مع الأشخاص وتبادل معارفك المهنية

أنشئ حسابًا أو سجّل الدخول للانضمام إلى مجتمعك المهني.

متابعة

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
تم إضافة السؤال من قبل Mohannad Bakbouk , Full Stack Web Developer , Almohtaseb
تاريخ النشر: 2016/10/21
Shilpa Kotian
من قبل 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

المزيد من الأسئلة المماثلة

هل تحتاج لمساعدة في كتابة سيرة ذاتية تحتوي على الكلمات الدلالية التي يبحث عنها أصحاب العمل؟