25. Write a program in java to input nine integers in three rows and three columns. Calculate and print sum of each row?

class SumRow
{
                public static void main(String args[])
                {
                                int i,j,s=0;
                                int n[][]={{1,2,3},{4,5,6},{7,8,9}};
                                for(i=0;i<3;i++)
                                                {
                                                s=0;
                                                for(j=0;j<3;j++)
                                                                s+=n[i][j];
                                                System.out.println((i+1)+" Rows Sum : "+s);
                                                }
                }
}

JAVA 25.PNG

Advertisements

Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: