Answered step by step
Verified Expert Solution
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started