Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

convert the source codes written in C below to Java applying the concept of Encapsulation #include int factorial(int n) { int fact = 1; for

convert the source codes written in C below to Java applying the concept of Encapsulation

#include

int factorial(int n)

{

int fact = 1;

for (int i = 1; i <= n; ++i) {

fact *= i;

}

return fact;

}

int num1 = 8, num2 = 3;

int main()

{

printf("In C ");

printf("Factorial of %d is %d ", num1, factorial(num1));

printf("Factorial of %d is %d ", num2, factorial(num2));

return 0;

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

Students also viewed these Programming questions

Question

Explain the process of MBO

Answered: 1 week ago

Question

Given and find P(AB). If, further, are A and B independent?

Answered: 1 week ago