i changed it to

Code:


#include <stdio.h>

int main()   { //star
	int i,j,k,temp;
	int rows = 4;
   int cols = 4;
   int jndex,input;
//	int sum2=0;  sum2 is never used

   /* You can't make an array without telling it's size. rows and cols
   have not been assigned a value, yet. 
   */
   int matrix[50][50];
//	int matrix[rows][cols];
//	int sum[rows][cols];
   int sum[50][50];
//	int temp1[rows][cols];
   int temp1[50][50];
//	int transpose [cols][rows];
   int transpose [50][50];
	int index,kndex,tndex,gndex,lndex;
   int rows_sum[4];
   //int rows_sum[rows]; //rows could be ANY value, still.

/* your program isn't designed for this
   printf("enter rows and cols [1..50] ==> ");
	scanf("%d %d",&rows,&cols);
*/
	printf("enter power:");
	scanf("%d",&input);

/* You can save yourself this code, just by making the array initialize to
zero's, when you declare it:

row_sum[4] = { 0 };

This only works when you first declare them, not at any later time
*/
	for (index = 0; index < rows; index++)
	{
	    rows_sum[index]=0;
		for (kndex = 0; kndex < cols; kndex++)
		{
			matrix[index][kndex] = 0;
			sum[index][kndex] = 0;
			temp1[index][kndex] = 0;
			transpose[index][kndex] = 0;
		}//end inner for
	}//end outer for
	printf("enter numbers in a row for a matrix:"); //stat input
	for (index = rows - 1;index >= 0; index--)
	{
		for (kndex = cols - 1; kndex >= 0; kndex--)
		{
			scanf("%d", &matrix[index][kndex]);
			transpose[kndex][index] = matrix[index][kndex];
		}
	}
	i = getchar();  //needed because of scanf()
	//end input
	//start power operation
	//  rows sum
	for (index = 0; index < rows; index++)
	{
		for (kndex = 0; kndex < cols; kndex++)
			rows_sum[index]=rows_sum[index]+matrix[index][kndex];
		printf("\n");
	}
      //  end rows sum

for(i = 0; i <rows - 1; i++)  {       
   for(j = i + 1; j <rows; j++)  {   
      if(rows_sum[i] >rows_sum[j])   {
         temp = rows_sum[i];
         rows_sum[i] = rows_sum[j];
         rows_sum[j] = temp;
      }  //you missed this brace :)
         //now swap the rows elements, from row j to row i
         for(k = 0; k <rows; k++)   {
            temp = matrix[i][k];                                      //here is line 62
            matrix[i][k] = matrix[j][k];
            matrix[j][k] = temp;
         }
      }
   }

   //print the swapped matrix
   for(i = 0; i < rows; i++)  {
      putchar('\n');
      for(j = 0; j < cols; j++)  
         printf(" %d", matrix[i][j]);
   }

   i = getchar();
   return 0;

}//end main