/* Generating a new array by factorial of corresponding element in the existing array. */
#include <stdio.h>
int main()
{
int n, i, j, x;
printf("Enter the elements of array: ");
scanf("%d", &n);
int a[n];
for(i = 0; i < n; i++){
printf("Enter element %d: ", i+1);
scanf("%d", &a[i]);
}
printf("The array you entered is .....\n");
for(i = 0; i < n; i++)
printf("%d ", a[i]);
printf("\nNew array of factorial of corresponding number is .....\n");
for(i = 0; i < n; i++){
x = 1;
for(j = 1; j <= a[i]; j++){
x *= j;
}
printf("%d ", x);
}
return 0;
}
Comments
Post a Comment