Witam tworze program który dodaje elemnty macierzy w podanym zakresie .Nie wiem czemu ale program sumuje tylko 1 wiersz .
Dziękuję za pomoc
#include <stdio.h>
#include <stdlib.h>
int main()
{
int i=0,j=0,tab[10][20];
int p,q,r,s,sum=0;
for(i=0; i<10; i++)
{
for(j=0; j<20; j++)
{
tab[i][j]=i+10;
}
}
for(i=0; i<10; i++)
{
for(j=0; j<20; j++)
{
printf("%i ",tab[i][j]);
}
printf("\n");
}
printf("Podaj p(gora wiersza)\n");
scanf("%d",&p);
printf("Podaj q(dol wiersza)\n");
scanf("%d",&q);
printf("Podaj r(gora kolumny)\n");
scanf("%d",&r);
printf("Podaj s(dol kolumny)\n");
scanf("%d",&s);
for(p; p<=q; p++)
{
for(r; r<=s; r++)
{
sum=sum+tab[p][r];
}
}
printf("\nsum=%d\n",sum);
return 0;
}