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=10; scanf("%s", &T); for(x=0;x<=11;x++) { for(y=0; y<=11; y++) scanf("%lf", &M[x][y]); } for(z=0; z<=10;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; }
#include
ReplyDeleteint main()
{
int i,j,b=11;
float a[12][12],s=0.0,m=0.0,x=0.0;
char c;
scanf("%c",&c);
for(i=0;i<=11;i++)
{
for(j=0;j<=11;j++)
{
scanf("%f",&a[i][j]);
if(j<b && i!=11){
s=s+a[i][j];
m++;
}
}
b--;
}
if(c=='S'){
printf("%.1f\n",s);
}
else if(c=='M')
{
x=s/m;
printf("%.1f\n",x);
}
return 0;
}
#include
ReplyDeleteint main()
{
int i,j,b=11;
float a[12][12],s=0.0,m=0.0,x=0.0;
char c;
scanf("%c",&c);
for(i=0;i<=11;i++)
{
for(j=0;j<=11;j++)
{
scanf("%f",&a[i][j]);
if(j<b && i!=11){
s=s+a[i][j];
m++;
}
}
b--;
}
if(c=='S'){
printf("%.1f\n",s);
}
else if(c=='M')
{
x=s/m;
printf("%.1f\n",x);
}
return 0;
}