I am giving a 1000 digit number as input, and using this program to find max product of 5 consecutive integers. The array a is used to hold the sequence with highest product.I am getting an unexpected answer(I suspect the problem to be in conversion from char to int)
#include <stdio.h>
int main(void)
{
int a[5],c=0,b,i=1;
char *num[1000];
scanf("%s",&num);
while(i<5)
{
a[i]=num[i]-'0';
i++;
}
while(i<1000)
{
b=(char)num[i]-'0';
if(a[c]<b)
{
a[c]=b;
c=(c+1)%5;
}i++;
}
printf("%d",a[0]*a[1]*a[2]*a[3]*a[4]);
return 0;
}