Question: 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
Get step-by-step solutions from verified subject matter experts
