Contact Learn C
Copy Program Share Program

Program 286: Program to print sum of Columns in matrix using GOTO Statement

Program 286: Program to print sum of Columns in matrix using GOTO Statement

#include<stdio.h>
main()
{ 
 int i,j,rows,col,sum_rows,sum_col,k=0;
 printf("Enter number of rows and columns of a matrix\n");
 scanf("%d %d",&rows,&col);
int a[rows][col];

  //Taking input of matrix
    printf("Enter Matrix 1\n");
    for(i=0;i<rows;i++)
    {
       for(j=0;j<col;j++)
      {
     scanf("%d",&a[i][j]);
      }
    }
    
    printf("Given /matrix is\n");
        for(i=0;i<rows;i++)
         {
         for(j=0;j<col;j++)
         {
           printf("%d\t",a[i][j]);
           }
  
           printf("\n");
           }
  k=0;
  i=0;
   FirstLoop:
   { 
        if(i<col)
      {
          sum_col=0;
          j=0;
          SecondLoop:
          {
           if(j<rows)
           {
            sum_col+=a[j][i];
            j++;
            goto SecondLoop;
            }
          }
            printf("Sum of %d Column is %d\n",k,sum_col);
            k++;
            i++;
            goto FirstLoop; 
         }
  }   
}
Explanation:

//Coming Soon

Output:
Program to print sum of Columns in matrix using GOTO Statement






No comments:

Post a Comment

Download App and Learn when ever you want

Get it on PlayStore
Get it on Amazon App Store
Get it on Aptoide