C Saved Program: beautiful-rain

facebook share

Here's the online compiler accompanied with IDE at your service. This is a saved code by one of our users. Try it out or save your own from the IDE page and don't forget to leave a feedback. You can find that at the bottom of the page.


#include<stdio.h>
int main()
{
int a[100][100];
int n;
int i,j;
int sum=-10001;
int temp_sum;
scanf("%d",&n);
for(i=0;i<n;i++)
for(j=0;j<n;j++)
scanf("%d",&a[i][j]);
for(i=0;i<n;i++)
{ temp_sum=0;
for(j=0;j<n;j++)
{
temp_sum=temp_sum+a[i][j];
}
if(temp_sum>sum)
{
sum=temp_sum;
}
}
for(i=0;i<n;i++)
{ temp_sum=0;
for(j=0;j<n;j++)
{
temp_sum=temp_sum+a[j][i];
}
if(temp_sum>sum)
{
sum=temp_sum;
}
}
temp_sum=0;
for(i=0;i<n;i++)
{
temp_sum+=a[i][i];
}
if(temp_sum>sum)
{
sum=temp_sum;
}
temp_sum=0;
for(i=0;i<n;i++)
{
temp_sum+=a[i][n-1-i];
}
if(temp_sum>sum)
{
sum=temp_sum;
}
printf("%d",sum);
return 0;
}
Execute

Output

Press the execute button or CTRL + enter to run code.

Inputs