Before seeing the solution make sure that you tried enough. Don’t paste the whole code, just find out the logic. If you stuck in trouble, just inform me on comment.
/**Bismillahir Rahmanir Rahim.**/
#include <stdio.h>
int main()
{
double a=0.0, M[12][12];
char T[2];
int C,x,y,z,p=0;
scanf("%s", &T);
for(x=0;x<=11;x++)
{
for(y=0; y<=11; y++)
scanf("%lf", &M[x][y]);
}
for(z=1; z<=11;z++)
{
for(C=0; C<=p;C++)
a+=M[z][C];
p++;
}
if(T[0]=='S')
printf("%.1lf\n",a);
else if(T[0]=='M')
{
a=a/66.0;
printf("%.1lf\n",a);
}
return 0;
}
This comment has been removed by the author.
ReplyDelete#include
ReplyDeleteint main()
{
int i , j,p=0 ;
double N[i][j], sum =0.0 ;
char c[2];
scanf ("%s",&c);
for(i=0;i<12;i++)
{
for(j=0;j<12;j++)
{
scanf ("%lf",&N[i][j]);
if (i>j)
{
sum=sum+N[i][j];
}
}
}
if (c[0]=='S')
{
printf ("%.1lf\n",sum);
}
else if (c[0]=='M')
{
printf ("%.1lf\n",sum/66.0);
}
return 0;
}
why runtime error