{"id":5549,"date":"2023-09-22T04:01:00","date_gmt":"2023-09-22T04:01:00","guid":{"rendered":"http:\/\/ebhor.com\/?p=5549"},"modified":"2023-09-22T09:44:59","modified_gmt":"2023-09-22T09:44:59","slug":"addition-of-two-matrix-in-c-programming","status":"publish","type":"post","link":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/","title":{"rendered":"Addition of Two Matrix in C Programming"},"content":{"rendered":"\n

A Matrix is Two dimensional array<\/a> that have number of rows and columns. Addition of Two Matrix in C Programming is very easy.<\/p>\n\n\n\n

To write program for adding two matrix is same as we perform matrix addition<\/a> in mathematics.<\/p>\n\n\n\n

To Add Two Numbers rows and columns of both matrix should be same.<\/p>\n\n\n\n

Element of each row and column of matrix A will added with same row and column element in matrix B.<\/p>\n\n\n\n

The sum of both matrix will produce same row and column matrix in resultant matrix.<\/p>\n\n\n\n

Example:<\/strong> Write a program to add two matrix. Firstly, ask from user order of matrix( number of rows and column). <\/p>\n\n\n\n

Then take the elements of matrix from user as a input and print the resultant matrix<\/p>\n\n\n\n

For example, <\/p>\n\n\n\n

if a user input order as 3,3, i.e., three rows and three columns and
First matrix        <\/strong>              
1             2             3
4             5             6
7             8             9<\/strong>
<\/p>\n\n\n\n

Second matrix:<\/strong>
9             8             7
6             5             4
3             2             1<\/strong>
<\/p>\n\n\n\n


then the output of the program (addition of two 3*3 matrix in c) is:

10           10           10
10           10           10
10           10           10<\/strong><\/p>\n\n\n\n

Steps for Addition of Two Matrix in C Programming<\/p>\n\n\n\n

    \n
  1. Declare Three matrix f,s and sum.<\/li>\n\n\n\n
  2. Take elements for matrix f and s.<\/li>\n\n\n\n
  3. Add both matrix f and s and save to sum matrix.<\/li>\n\n\n\n
  4. Print the sum matrix.<\/li>\n<\/ol>\n\n\n\n

    Matrix addition program in C<\/strong><\/h2>\n\n\n\n
    \n#include \n int main()\n{\n   int m, n, i, j, f[10][10], s[10][10], sum[10][10];\n \n   printf(\"Enter the number of rows and columns of matrix\\n\");\n   scanf(\"%d%d\", &m, &n);\n   printf(\"Enter the elements of first matrix\\n\");\n \n  \t for (i = 0; i < m; i++)\n     \t{\t for (j = 0; j < n; j++)\n         \t\t{\tscanf(\"%d\", &f[i][j]);\n \t\t}\n\t}\n   printf(\"Enter the elements of second matrix\\n\");\n \n   \tfor (i = 0; i < m; i++)\n      \t{\tfor (j = 0 ; j < n; j++)\n         \t\t{\tscanf(\"%d\", &s[i][j]);\n   \t\t}\n\t}\n   printf(\"Sum of matrices= \\n\");\n   \n   \tfor (i = 0; i < m; i++) \n\t{\n     \t\t for (j = 0 ; j < n; j++) \n\t\t{\n         \t\t\tsum[i][j] = f[i][j] + s[i][j];\n         \t\t\tprintf(\"%d\\t\", sum[i][j]);\n      \t\t}\n      \tprintf(\"\\n\");\n   \t}\n return 0;\n}\n\n\n<\/pre>\n\n\n\n

    Number of rows and columns are controlled by variable m and n.<\/p>\n\n\n\n

    To avoid checking again row and column of both matrix it is accepted at only one place and used by both matrix.<\/p>\n\n\n\n

    Both Matrix elements are taken from user as per requirement user can also declare matrix elements in program.<\/p>\n\n\n\n

    OUTPUT<\/strong><\/p>\n\n\n\n

    Enter the number of rows and columns of matrix\n\n3\n3\nEnter the elements of first matrix\n2\n3\n4\n5\n6\n7\n8\n9\n10\nEnter the elements of second matrix\n11\n12\n13\n14\n15\n16 \n17\n18\n19\n\n\nSum of matrices= \n13\t15\t17\t\n19\t21\t23\t\n25\t27\t29\t\n\n<\/pre>\n\n\n\n

    Hope you got how to add two matrix in C. Similar way you can also write program to multiply two matrix.<\/p>\n","protected":false},"excerpt":{"rendered":"

    A Matrix is Two dimensional array that have number of rows and columns. Addition of Two Matrix in C Programming is very easy. To write program for adding two matrix is same as we perform matrix addition in mathematics. To Add Two Numbers rows and columns of both matrix should be same. Element of each … Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[283],"tags":[93,282],"yoast_head":"\nAddition of Two Matrix in C Programming - Ebhor.com<\/title>\n<meta name=\"description\" content=\"Addition of Two Matrix in C Programming concept of addition of two matrix explanation example of matrix addition with result two dimension array example\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Addition of Two Matrix in C Programming - Ebhor.com\" \/>\n<meta property=\"og:description\" content=\"Addition of Two Matrix in C Programming concept of addition of two matrix explanation example of matrix addition with result two dimension array example\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/\" \/>\n<meta property=\"og:site_name\" content=\"Ebhor.com\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/ebhorcom\/\" \/>\n<meta property=\"article:published_time\" content=\"2023-09-22T04:01:00+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-09-22T09:44:59+00:00\" \/>\n<meta name=\"author\" content=\"manish\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"manish\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/\"},\"author\":{\"name\":\"manish\",\"@id\":\"https:\/\/www.ebhor.com\/#\/schema\/person\/6a63908fdbbb27289970569ebd2e709b\"},\"headline\":\"Addition of Two Matrix in C Programming\",\"datePublished\":\"2023-09-22T04:01:00+00:00\",\"dateModified\":\"2023-09-22T09:44:59+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/\"},\"wordCount\":502,\"publisher\":{\"@id\":\"https:\/\/www.ebhor.com\/#organization\"},\"keywords\":[\"array\",\"C Programming\"],\"articleSection\":[\"C Programming\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/\",\"url\":\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/\",\"name\":\"Addition of Two Matrix in C Programming - Ebhor.com\",\"isPartOf\":{\"@id\":\"https:\/\/www.ebhor.com\/#website\"},\"datePublished\":\"2023-09-22T04:01:00+00:00\",\"dateModified\":\"2023-09-22T09:44:59+00:00\",\"description\":\"Addition of Two Matrix in C Programming concept of addition of two matrix explanation example of matrix addition with result two dimension array example\",\"breadcrumb\":{\"@id\":\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.ebhor.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Addition of Two Matrix in C Programming\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.ebhor.com\/#website\",\"url\":\"https:\/\/www.ebhor.com\/\",\"name\":\"Ebhor.com\",\"description\":\"Read The Latest Post Java, Css, Html, Php learning articles\",\"publisher\":{\"@id\":\"https:\/\/www.ebhor.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.ebhor.com\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.ebhor.com\/#organization\",\"name\":\"Ebhor.com\",\"url\":\"https:\/\/www.ebhor.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.ebhor.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.ebhor.com\/wp-content\/uploads\/2021\/05\/cropped-cropped-cropped-ebhor_logo_100x.jpg\",\"contentUrl\":\"https:\/\/www.ebhor.com\/wp-content\/uploads\/2021\/05\/cropped-cropped-cropped-ebhor_logo_100x.jpg\",\"width\":100,\"height\":100,\"caption\":\"Ebhor.com\"},\"image\":{\"@id\":\"https:\/\/www.ebhor.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/ebhorcom\/\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.ebhor.com\/#\/schema\/person\/6a63908fdbbb27289970569ebd2e709b\",\"name\":\"manish\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.ebhor.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/def43b1d916cff76638fa6c47604a2bb?s=96&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/def43b1d916cff76638fa6c47604a2bb?s=96&r=g\",\"caption\":\"manish\"},\"description\":\"A Learner and Teacher\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Addition of Two Matrix in C Programming - Ebhor.com","description":"Addition of Two Matrix in C Programming concept of addition of two matrix explanation example of matrix addition with result two dimension array example","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/","og_locale":"en_US","og_type":"article","og_title":"Addition of Two Matrix in C Programming - Ebhor.com","og_description":"Addition of Two Matrix in C Programming concept of addition of two matrix explanation example of matrix addition with result two dimension array example","og_url":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/","og_site_name":"Ebhor.com","article_publisher":"https:\/\/www.facebook.com\/ebhorcom\/","article_published_time":"2023-09-22T04:01:00+00:00","article_modified_time":"2023-09-22T09:44:59+00:00","author":"manish","twitter_card":"summary_large_image","twitter_misc":{"Written by":"manish","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/#article","isPartOf":{"@id":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/"},"author":{"name":"manish","@id":"https:\/\/www.ebhor.com\/#\/schema\/person\/6a63908fdbbb27289970569ebd2e709b"},"headline":"Addition of Two Matrix in C Programming","datePublished":"2023-09-22T04:01:00+00:00","dateModified":"2023-09-22T09:44:59+00:00","mainEntityOfPage":{"@id":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/"},"wordCount":502,"publisher":{"@id":"https:\/\/www.ebhor.com\/#organization"},"keywords":["array","C Programming"],"articleSection":["C Programming"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/","url":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/","name":"Addition of Two Matrix in C Programming - Ebhor.com","isPartOf":{"@id":"https:\/\/www.ebhor.com\/#website"},"datePublished":"2023-09-22T04:01:00+00:00","dateModified":"2023-09-22T09:44:59+00:00","description":"Addition of Two Matrix in C Programming concept of addition of two matrix explanation example of matrix addition with result two dimension array example","breadcrumb":{"@id":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.ebhor.com\/addition-of-two-matrix-in-c-programming\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.ebhor.com\/"},{"@type":"ListItem","position":2,"name":"Addition of Two Matrix in C Programming"}]},{"@type":"WebSite","@id":"https:\/\/www.ebhor.com\/#website","url":"https:\/\/www.ebhor.com\/","name":"Ebhor.com","description":"Read The Latest Post Java, Css, Html, Php learning articles","publisher":{"@id":"https:\/\/www.ebhor.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.ebhor.com\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.ebhor.com\/#organization","name":"Ebhor.com","url":"https:\/\/www.ebhor.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.ebhor.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.ebhor.com\/wp-content\/uploads\/2021\/05\/cropped-cropped-cropped-ebhor_logo_100x.jpg","contentUrl":"https:\/\/www.ebhor.com\/wp-content\/uploads\/2021\/05\/cropped-cropped-cropped-ebhor_logo_100x.jpg","width":100,"height":100,"caption":"Ebhor.com"},"image":{"@id":"https:\/\/www.ebhor.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/ebhorcom\/"]},{"@type":"Person","@id":"https:\/\/www.ebhor.com\/#\/schema\/person\/6a63908fdbbb27289970569ebd2e709b","name":"manish","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.ebhor.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/def43b1d916cff76638fa6c47604a2bb?s=96&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/def43b1d916cff76638fa6c47604a2bb?s=96&r=g","caption":"manish"},"description":"A Learner and Teacher"}]}},"_links":{"self":[{"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/posts\/5549"}],"collection":[{"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/comments?post=5549"}],"version-history":[{"count":2,"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/posts\/5549\/revisions"}],"predecessor-version":[{"id":16593,"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/posts\/5549\/revisions\/16593"}],"wp:attachment":[{"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/media?parent=5549"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/categories?post=5549"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.ebhor.com\/wp-json\/wp\/v2\/tags?post=5549"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}