/*Given an array arr[] of n integers, construct a Product Array prod[] (of same size) such that prod[i] is equal to the product of all the elements of arr[] except arr[i].

My code is printing garbage value.Pls someone suggest me what is wrong and how can I correct it..Thank you */

include<stdio.h>

main()
{
int i,j,a;
int sum=1;
int vari=1;
int array[5]={1,2,3,4,5};
int temp[4];
while(a<=4)
{
printf("sum");
for(i=0;i<=4;i++)
{
if(i==a)
i++;
else
sum=sum*array[i];
}
temp[j]=sum;
j++;
a++;
sum=vari;
}
for(j=0;j<=4;j++)
printf("%d\n",temp[j]);
}

package grossmontbank;
import java.util.Scanner;
public class GrossmontBank
{
//class variables (global - accessible throughout this class)
//scanner object to be used throughout
private static Scanner input = new Scanner(System.in);
//array ...