Mar

22

#include<stdio.h>
#include<alloc.h>
int *fact(int *p){
int f=1;
int j;
for(j=1;j<=*p;j++){
f=f*j;
}
return(&f);
}
void main(){
int *ptr;
int n,i,*ff;
printf(“How many numbers you want to enter: “);
scanf(“%d”,&n);
ptr=(int*) malloc(n*sizeof(int));
printf(“Enter %d numbers: \n”,n);
for(i=0;i<n;i++){
scanf(“%d”,(ptr+i));
}
for(i=0;i<n;i++){
ff=fact(ptr+i);
printf(“Factorail of %d is: %d\n”,*(ptr+i),*ff);
}
}


Leave a Reply