Write a c program that reads a sequence of maximum 9 integers, prints the sum of every contiguous sub sequence of it.
I am able to print all the contiguous sub sequences but not able to print the sum of each sub sequence. Please help me learn. I am a naive learner. Forgive me for my inefficiency in coding. Given below is what I was able to do.
#include<stdio.h>
int main()
{
int a[9];
int i,j,k,sum[9]={0};
for(i=0;i<9;i++)
scanf("%d",&a[i]);
for(i=0;i<9;i++)
{
for(j=i;j<9;j++)
{
for(k=i;k<j+1;k++)
printf("+%d ",a[k]);
printf("\n");
}
}
getch();
}