i/p
array a holds 1 2 3 4
o/p of array b is 24 12 8 6
#include<stdio.h> int main() { int n,i,j,a[100],b[100]; scanf("%d",&n); for(i=0;i<n;i++) { scanf("%d",&a[i]); } for(i=0;i<n;i++) {
b[i]=1; for(j=0;j<n;j++) { if(i==j) { } else { b[i]=b[i]*a[j]; } } } for(i=0;i<n;i++) printf("%d ",b[i]); return 0; }
No comments:
Post a Comment