Monday, 5 November 2012

c program for sum of diagonal elements in matrix

For beginners
{I am going write the c program but before you need a c compiler(software).there are a lot of compilers(software) for windows 7  like Code::Blocks,dev c++ Download dev c++ its free and install it in your computer.open  dev c++ go to file-->new-->source file.}  

#include<conio.h>
#include<stdio.h>
main()
{
      int m[10][10],a,b,c,d,sum=0;
      printf(" enter row and colomn matrix");
      scanf("%d%d",&a,&b);
      printf(" enter the elements");
      for(c=0;c<a;c++)
      {
                      for(d=0;d<b;d++)
                      {
                                      scanf("%d",&m[c][d]);
                                      }
                                      }
                                      printf("the matrix is");
                                      for(c=0;c<a;c++){
      printf("\n");
      for(d=0;d<b;d++)
      {
                      printf("%d",m[c][d]);
                      }
                      }
                      printf("the the diagnal element is");
                       for(c=0;c<a;c++)
      {
                      for(d=0;d<b;d++)
                      {if(c==d)
                      sum=sum+m[c][d];
                      }
                      }
                      printf("%d",sum);
                      getch();
                      }
                      

For beginners
{After typing this program go to execute-->compile & run-->a window will pop-up-->give file name:(anything u like)-->save as type: c source files-->click save.}

IS IT HELPFIL? comment.

2 comments:

  1. HDFS is a Java-based file system that provides scalable and reliable data storage,
    and it was designed to span large clusters of commodity servers. HDFS has demonstrated production scalability of up to 200 PB of storage and a single cluster of 4500 servers, supporting close to a billion files and blocks.
    http://www.computaholics.in/2015/12/hdfs.html

    ReplyDelete
  2. This comment has been removed by the author.

    ReplyDelete