Lab Repoet#05cpp
Lab Repoet#05cpp
int fic = 1;
int factorial(int n) {
if (n == 0 || n == 1) {
return fic;
} else {
fic = fic * n;
return factorial(n - 1);
}
}
int main() {
int num;
cout << "Enter a non-negative integer for factorial: ";
cin >> num;
cout << "Factorial of " << num << " is " << factorial(num) << endl;
int n;
cout << "Enter the number of elements in the array: ";
cin >> n;
int arr[n];
cout << "Enter the elements of the array:" << endl;
for (int i = 0; i < n; ++i) {
cin >> arr[i];
}
cout << "The sum of the array elements is: " << linearsum(arr, n) << endl;
return 0;
}