gdata.io.handleScriptLoaded({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$georss":"http://www.georss.org/georss","xmlns$thr":"http://purl.org/syndication/thread/1.0","xmlns$blogger":"http://schemas.google.com/blogger/2008","id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268"},"updated":{"$t":"2023-07-30T02:11:08.392-07:00"},"category":[{"term":"C Programs"},{"term":"Pointers"},{"term":"string"},{"term":"Array"},{"term":"Learn C"},{"term":"Fundamental"},{"term":"Pattern"},{"term":"control sturctures"},{"term":"searching and sorting"},{"term":"recursion"},{"term":"List of C Programs"},{"term":"Structures"},{"term":"C Turbo Compiler"},{"term":"File Handling"},{"term":"Contents"},{"term":"Common Programming Error"},{"term":"functions"},{"term":"Dynamic memory allcation"}],"title":{"type":"text","$t":"C Programming Tutorial"},"subtitle":{"type":"html","$t":"It is a blog about c programming. Here we provide c programs and tutorials to enhance your skills."},"link":[{"rel":"http://schemas.google.com/g/2005#feed","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/-/Array?alt\u003djson-in-script\u0026max-results\u003d50"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/-/Array?alt\u003djson-in-script\u0026max-results\u003d50"},{"rel":"alternate","type":"text/html","href":"http://www.comp-psyche.com/search/label/Array"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"generator":{"version":"7.00","uri":"https://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"5"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"50"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-4492828263261354620"},"published":{"$t":"2014-01-29T05:48:00.000-08:00"},"updated":{"$t":"2014-04-16T01:00:22.350-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Array"}],"title":{"type":"text","$t":"C PROGRAMS : ARRAYS"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAMS : ARRAYS \u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays3.html#16\" name\u003d\"16\"\u003e16. Programs to multiply two Matrices\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main( )\n{\n // Declaring variable a, b, c with max size\u003d10 X 10\n int a[10][10],b[10][10],c[10][10];\n \n // Declaring variable m, n, p, q \u003d size of matrix entered by user\n int m, n, p, q;\n \n // Declaring variable i, j, k \u003d to iterate loop\n int i, j, k;\n\n // Inputing size of first matrix\n printf(\"Enter the size of first matrices : \\n\");\n \n printf(\"Enter number of rows : \");\n scanf(\"%d\",\u0026amp;m);\n \n printf(\"Enter number of columns : \");\n scanf(\"%d\",\u0026amp;n);\n \n // Inputing size of second matrix\n printf(\"Enter the size of second matrices : \\n\");\n \n printf(\"Enter number of rows : \");\n scanf(\"%d\",\u0026amp;p);\n \n printf(\"Enter number of columns : \");\n scanf(\"%d\",\u0026amp;q);\n\n\n // Checking if multiplication is possible or not if possible then proceed\n if(n\u003d\u003dp)\n {\n // Inputing first matrx elemets\n printf(\"Enter first matrices elements : \");\n \n for(i\u003d0;i\u0026lt;m;i++)\n {\n  for(j\u003d0;j\u0026lt;n;j++)\n  {\n   scanf(\"%d\",\u0026amp;a[i][j]);\n  }\n }\n \n // Inputing second matrx elemets\n printf(\"Enter second matrix elements : \");\n \n for(i\u003d0;i\u0026lt;m;i++)\n {\n  for(j\u003d0;j\u0026lt;n;j++)\n  {\n   scanf(\"%d\",\u0026amp;b[i][j]);\n  }\n }\n \n // Performing multiplication\n for(i\u003d0;i\u0026lt;m;i++)\n {\n  for(j\u003d0;j\u0026lt;n;j++)\n  {\n   c[i][j]\u003d0;\n   for(k\u003d0;k\u0026lt;n;k++)\n   {\n   c[i][j]\u003dc[i][j]+a[i][k]*b[k][j];\n   }\n  }\n }\n \n // Printing multiplied matrix\n printf(\"The multiplication of Matrices : \\n\"); \n for(i\u003d0;i\u0026lt;m;i++)\n {\n  for(j\u003d0;j\u0026lt;n;j++)\n  {\n  printf(\"%d \",c[i][j]);\n  }\n  \n  printf(\"\\n\");\n }\n}\n\n else\n printf(\"Multiplication is not possible\");\n\n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays3.html#17\" name\u003d\"17\"\u003e17. Program to print a diagonal matrix with diagonal value enter by user\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variale a with size \u003d 4 X 4\n int a[4][4],i,j;\n \n // Declaring varibale d \u003d diagonal value by user\n int d;\n \n // Inputing diagonal value\n printf(\"Enter diagonal value : \");\n scanf(\"%d\",\u0026amp;d);\n \n // Setting diagonal value as \"d\" and all other value as \"0\"\n for(i\u003d0;i\u0026lt;4;i++)\n {\n  for(j\u003d0;j\u0026lt;4;j++)\n  {\n   if(i\u003d\u003dj)\n   a[i][j]\u003dd;\n   else\n   a[i][j]\u003d0;\n  }\n }\n \n // Printing diagonal matrix\n for(i\u003d0;i\u0026lt;4;i++)\n {\n \n  for(j\u003d0;j\u0026lt;4;j++)\n  printf(\"%2d\",a[i][j]);\n  printf(\"\\n\");\n }\n  \n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays3.html#18\" name\u003d\"18\"\u003e18. Program to print a anti diagonal matrix with diagonal value enter by user\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variale a with size \u003d 4 X 4\n int a[4][4],i,j;\n \n // Declaring varibale d \u003d diagonal value by user\n int d;\n \n // Inputing diagonal value\n printf(\"Enter diagonal value : \");\n scanf(\"%d\",\u0026amp;d);\n \n // Setting diagonal value as \"d\" and all other value as \"0\"\n for(i\u003d0;i\u0026lt;4;i++)\n {\n  for(j\u003d0;j\u0026lt;4;j++)\n  {\n   if(i+j\u003d\u003d3)\n   a[i][j]\u003dd;\n   else\n   a[i][j]\u003d0;\n  }\n }\n \n // Printing anti diagonal matrix\n for(i\u003d0;i\u0026lt;4;i++)\n {\n \n  for(j\u003d0;j\u0026lt;4;j++)\n  printf(\"%2d\",a[i][j]);\n  printf(\"\\n\");\n }\n  \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays3.html#19\" name\u003d\"19\"\u003e19. Program to print the sum of diagonal values and anti-diagonal values of a matrix\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring 2D array\n int a[4][4];\n \n // Declaring variable i, j to iterate loop\n int i, j;\n \n // Declaring variabl sd\u003dto store sum of diagonal value, sa\u003dstore sum of anti diagonal value\n int sd\u003d0, sa\u003d0; \n \n // Inputing matrix\n printf(\"Enter matrix element of size 4 X 4 : \");\n for(i\u003d0;i\u0026lt;4;i++)\n {\n  for(j\u003d0;j\u0026lt;4;j++)\n  {\n   scanf(\"%d\",\u0026amp;a[i][j]);\n  }\n }\n \n // Calculating sum of diagonal values and anti diagonal values\n for(i\u003d0;i\u0026lt;4;i++)\n {\n  for(j\u003d0;j\u0026lt;4;j++)\n  {\n   if(i\u003d\u003dj)\n   sd\u003dsd+a[i][j];\n   \n   if(i+j\u003d\u003d3)\n   sa\u003dsa+a[i][j];\n  }\n }\n\n // Printing element of matrix \n printf(\"\\nEntered elements in matrix : \\n\");\n for(i\u003d0;i\u0026lt;4;i++)\n {\n  for(j\u003d0;j\u0026lt;4;j++)\n  {\n   printf(\"%d \",a[i][j]);\n  }\n  printf(\"\\n\");\n }\n\n // Printing sum and diagonal of matrix\n printf(\"\\nSum of diagonal values : %d \",sd);\n printf(\"\\nSum of anti diagonal values : %d \",sa);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/4492828263261354620/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-arrays3.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/4492828263261354620"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/4492828263261354620"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-arrays3.html","title":"C PROGRAMS : ARRAYS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-8615950276239009616"},"published":{"$t":"2014-01-29T05:42:00.001-08:00"},"updated":{"$t":"2014-04-16T00:59:38.072-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Array"}],"title":{"type":"text","$t":"C PROGRAMS : ARRAYS"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAMS : ARRAYS\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays2.html#p11\" name\u003d\"p11\"\u003e11. Program to generate histogram of entered number\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declarring array to enter elements\n int a[10];\n \n // Declaring variable \"i\" and \"j\" to iterate loop\n int i, j;\n \n // Inputting 10 numbers\n printf(\"Enter 10 numbers :\\n\");\n for(i\u003d0;i\u0026lt;10;i++)\n {\n  scanf(\"%d\",\u0026amp;a[i]);\n }\n \n // Generating histogram\n printf(\"%s %12s %15s\\n\",\"Element\", \"Value\", \"Hisogram\");\n for(i\u003d0;i\u0026lt;10;i++)\n {\n  printf(\"%4d %12d           \",i, a[i]);\n  for(j\u003d0;j\u0026lt;a[i]; j++)\n  {\n   printf(\"*\");\n  }\n  printf(\"\\n\");\n }\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays2.html#p12\" name\u003d\"p12\"\u003e12. Program to enter values into a two-dimensional integer array of size (4 X 3) and then display it in matrix form\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable info with row size \u003d 4 and column size \u003d 3\n int info[4][3];\n \n // Declaring variable \"i\" and \"j\" to iterate loop\n int i, j;\n \n // Inputting value\n \n for(i\u003d0;i\u0026lt;4;i++)\n {\n  for(j\u003d0;j\u0026lt;3;j++)\n  {\n   printf(\"Enter value of info[%d][%d] : \",i ,j);\n   scanf(\"%d\",\u0026amp;info[i][j]);\n  }\n }\n \n // Diplaying elements\n printf(\"Elements elements in matrix form :\\n\");\n for(i\u003d0;i\u0026lt;4;i++)\n {\n for(j\u003d0;j\u0026lt;3;j++)\n {\n  printf(\"%d \",info[i][j]);\n }\n printf(\"\\n\");\n }\n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays2.html#p13\" name\u003d\"p13\"\u003e13. Program to enter values into a two-dimensional integer array of size (4 X 3) and then display the elements of the second row\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable info with row size \u003d 4 and column size \u003d 3\n int info[4][3];\n \n // Declaring variable \"i\" and \"j\" to iterate loop\n int i, j;\n \n // Inputting value\n \n for(i\u003d0;i\u0026lt;4;i++)\n {\n  for(j\u003d0;j\u0026lt;3;j++)\n  {\n   printf(\"Enter value of info[%d][%d] : \",i ,j);\n   scanf(\"%d\",\u0026amp;info[i][j]);\n  }\n }\n \n // Diplaying elements of second row\n printf(\"Elements of second row : \");\n for(j\u003d0;j\u0026lt;3;j++)\n {\n  printf(\"%d \",info[1][j]);\n }\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays2.html#p14\" name\u003d\"p14\"\u003e14. Program to find the sum of elements that are greater than 5 within a two-dimensional array through a function receiving the array as arguments\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\n// funciton prototype\nint sum(int[][4], int, int);\n\nint main()\n{\n // Declaring variable a with row size\u003d2 and column size\u003d4\n int a[2][4];\n \n // Declaring variable \"i\" and \"j\" to iterate loop for rows and columns\n int i, j;\n \n // Declaring variable result \u003d to hold the returned result \n int result\u003d0;\n \n // Inputting elements\n for(i\u003d0;i\u0026lt;2;i++)\n {\n  for(j\u003d0;j\u0026lt;4;j++)\n  {\n   printf(\"Enter value of a[%d][%d] : \",i ,j);\n   scanf(\"%d\",\u0026amp;a[i][j]);\n  }\n }\n \n // Calling function sum \n result\u003dsum(a, 2, 4);\n \n // Printing returned result\n printf(\"Sum of elements \u0026gt; 5 in an array \u003d %d \",result);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\n\nint sum(int p[][4], int m, int n) // m is row size, n is column size\n{\n // Declaring variable s\u003dsum to hold the sum\n int s\u003d0;\n \n // Declaring variable \"i\" and \"j\" to iterate loop for rows and columns\n int i, j;\n \n // Calculating sum\n for(i\u003d0;i\u0026lt;m;i++)\n {\n  for(j\u003d0;j\u0026lt;n;j++)\n  {\n   // Checking whether element is greater than 5\n   if(p[i][j]\u0026gt;5)\n   {\n    s\u003ds+p[i][j];\n   }\n  }\n } \n \n // Returning sum\n return s;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays2.html#p15\" name\u003d\"p15\"\u003e15. Program To Accept 5 Student - Roll No, Marks in 3 Subjects of each student and Calculate Total, Average and Print it along with student roll Number\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring rn\u003droll no\n int rn[5];\n \n // Declaring 2D array \n int marks[5][3];\n \n // Declaring variable \"i\" and \"j\" to iterate loop\n int i,j;\n \n // Declaring variable s\u003dsum and avg\u003daverage\n int s[5]\u003d{0}, avg[5]\u003d{0};\n\n // Inputting name, roll no and marks\n for(i\u003d0;i\u0026lt;5;i++)\n {\n  printf(\"\\nEnter %d student Roll no : \",i+1);\n  scanf(\"%d\",\u0026amp;rn[i]); \n  \n  // Inputing stuent marks\n  for(j\u003d0;j\u0026lt;3;j++)\n  {\n   printf(\"Enter Marks of %d subject : \",j+1 );\n   scanf(\"%d\",\u0026amp;marks[i][j]); \n  }\n }\n \n // Calculating total and average\n for(i\u003d0;i\u0026lt;5;i++)\n {\n  for(j\u003d0;j\u0026lt;3;j++)\n  {\n   s[i]\u003ds[i]+marks[i][j];\n  }\n  \n  avg[i]\u003ds[i]/3;\n }\n \n // Printing details\n printf(\"\\nDetails of student : \\n\");\n for(i\u003d0;i\u0026lt;5;i++)\n {\n  printf(\"\\nStudent Roll Number : %d\",rn[i]);\n  printf(\"\\nStudent Total marks \u003d %d, Average marks \u003d %d\\n\",s[i],avg[i]);\n }\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/8615950276239009616/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-arrays2.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/8615950276239009616"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/8615950276239009616"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-arrays2.html","title":"C PROGRAMS : ARRAYS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-914039247296367942"},"published":{"$t":"2014-01-29T05:28:00.000-08:00"},"updated":{"$t":"2014-04-16T00:59:17.009-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Array"}],"title":{"type":"text","$t":"C PROGRAMS : ARRAYS"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAM : Arrays\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays1.html#p6\" name\u003d\"p6\"\u003e6. Program to find Minimum element in an array\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\nint main()\n{\n // Declaring variable a with size five to store five elements\n int a[5];\n \n // Declaring variable \"i\" to iterate loop\n int i;\n \n // Declaring variable min\u003dminimum\n int min;\n \n // Inputting Element of an array\n printf(\"Enter five element in an array : \\n\");\n for(i\u003d0;i\u0026lt;5;i++)\n {\n  scanf(\"%d\",\u0026amp;a[i]);\n }\n \n // Initialising min with first element assuming it to be minimum\n min\u003da[0];\n \n // Determining minimum element\n for(i\u003d0;i\u0026lt;5;i++)\n {\n if(min\u0026gt;a[i+1])\n min\u003da[i+1];\n }\n \n // Displaying minimum element\n printf(\"Minimum Element \u003d %d\",min);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\n\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays1.html#p7\" name\u003d\"p7\"\u003e7. Program to find highest minimum(-) temperature and lowest maximum(+) temperature\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main()\n{\n int i,j;\n int counternegative\u003d0, counterpositive\u003d0;\n int temp[12];\n int max\u003d0;\n int min\u003d0;\n printf(\"Enter temperature of 12 months : \" );\n \n for(i\u003d0;i\u0026lt;12;i++)\n {\n  scanf(\"%d\",\u0026amp;temp[i]); \n }\n \n for(i\u003d0;i\u0026lt;12;i++)\n {\n  if(temp[i]\u0026gt;0 \u0026amp;\u0026amp; counterpositive\u003d\u003d0)\n  {\n  min\u003dtemp[i];\n  counterpositive\u003d1;\n  }\n  \n  else if(temp[i]\u0026lt;0 \u0026amp;\u0026amp; counternegative\u003d\u003d0)\n  {\n  max\u003dtemp[i];\n  counternegative\u003d1;\n  }\n }\n \n for(i\u003d0;i\u0026lt;12;i++)\n {\n    if(temp[i]\u0026lt;0)\n    {\n     if(max\u0026lt;temp[i])\n     {\n     max\u003dtemp[i];\n     }\n    }\n    \n    else if(temp[i]\u0026gt;0)\n    {\n     if(min\u0026gt;temp[i])\n     {\n      min\u003dtemp[i];\n     }\n    }\n  }\n \n printf(\"Max negative temperature : %d \\n\",max);\n printf(\"Min positive temperature : %d \",min);\n \n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays1.html#p8\" name\u003d\"p8\"\u003e8. Program to accept 10 numbers and print first five numbers in original order and print last five numbers in reverse order\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main( )\n{ \n\n// Declaring variabel i \u003d for iteration of loop\nint i,a[10];\n\n// Inputting elements\nprintf(\"Enter 10 elements : \");\nfor(i\u003d0;i\u0026lt;10;i++)\n{\nscanf(\"%d\",\u0026amp;a[i]);\n}\n\n// Printing first 5 numbers in original order\nprintf(\"Printing first 5 numbers in original order : \");\nfor(i\u003d0;i\u0026lt;\u003d4;i++)\nprintf(\"%d \",a[i]);\n\n// Printing last five numbers in reverse order\nprintf(\"\\nPrinting last 5 numbers in reverse order : \");\nfor(i\u003d9;i\u0026gt;\u003d5;i--)\nprintf(\"%d \",a[i]);\n\ngetch( ); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nreturn 0;\n}\n\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays1.html#p9\" name\u003d\"p9\"\u003e9. Program showing Passing array to function. Program finds the average of 5 marks input by user\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\n/* We have declared return type as float since value to be returned \ni.e \"average\" is a float value. */\nfloat avg(float x[5])\n{\n      // Declaring variable sum to hold the sum of five elements entered\n   float sum\u003d0;\n   \n   // Declaring variable \"i\" to iterate loop\n   int i;\n   \n   // Calculating sum \n      for(i\u003d0;i\u0026lt;5;i++)\n      {\n              sum\u003dsum+x[i];\n      }\n      \n      // Returning average i.e sum/5\n      return sum/5;\n}\nint main()\n{\n    // Declaring array variale marks with maximum size \"5\"\n    float marks[5];\n    \n     // Declaring variable \"i\" to iterate loop\n     int i;\n    \n    // Inputting elements or marks\n    printf(\"Enter marks for five subject : \");\n    for(i\u003d0;i\u0026lt;5;i++)\n    {\n            scanf(\"%f\",\u0026amp;marks[i]);\n    }\n \n // Calling function and printing the returned resutl ( i.e average )\n printf(\"Average marks \u003d %f\",avg(marks));\n\n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\n\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays1.html#p10\" name\u003d\"p10\"\u003e10. Program to initialize a character array and display the it in reverse order\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main()\n{\n // Declaring variable names of size 5 and initializing it\n char names[5]\u003d{'h','e','l','l','o'};\n \n // Declaring variable \"i\" to iterate loop\n        int i;\n    \n        // Printing in reverse order\n        printf(\"Initialized characters in reverse order : \");\n  for(i\u003d4;i\u0026gt;\u003d0;i--)\n  {\n  printf(\"%c \",names[i]);\n }\n\n getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n return 0;\n}\n\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/914039247296367942/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-arrays1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/914039247296367942"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/914039247296367942"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-arrays1.html","title":"C PROGRAMS : ARRAYS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-1870062262272059193"},"published":{"$t":"2014-01-29T05:14:00.000-08:00"},"updated":{"$t":"2014-04-16T00:58:53.985-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Array"}],"title":{"type":"text","$t":"C PROGRAMS : ARRAYS"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eC PROGRAMS : Array\u003c/title\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays.html#p1\" name\u003d\"p1\"\u003e1. Program to accept elements in an array and display it\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main()\n{\n    // Declaring array variable with max size\u003d10\n    int a[10];\n\n   // Declaring variable i \u003d to iterate loop\n   int i;\n\n   // Inputting elements\n   printf(\"Enter 10 elements in an array : \");\n   for(i\u003d0; i\u0026lt;10; i++)\n   {\n        scanf(\"%d\",\u0026amp;a[i]);\n   }\n\n   // Displaying entered elements\n   printf(\"Entered elements are : \");\n    for(i\u003d0; i\u0026lt;10; i++)\n   {\n        printf(\"%d \",a[i]);\n   }\n\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e   // to hold the screen defined in conio.h\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e  \u0026nbsp;\u003c/span\u003e\u003c/pre\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e   getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n   return 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays.html#p2\" name\u003d\"p2\"\u003e2. Program to accept elements in an array and display sum of all the elements\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main()\n{\n    // Declaring array variable with size\u003d10\n    int a[10]; \n\n   // Declaring variable s\u003dsum to store the sum, i \u003d to iterate loop\n   int i, s\u003d0;\n\n   // Inputting elements\n   printf(\"Enter 10 elements in an array : \");\n   for(i\u003d0; i\u0026lt;10; i++)\n   {\n        scanf(\"%d\",\u0026amp;a[i]);\n   }\n\n   // Displaying entered elements\n printf(\"Entered elements are : \");\n    for(i\u003d0; i\u0026lt;10; i++)\n   {\n        printf(\"%d \",a[i]);\n   }\n\n   // Performing sum of all elements\n    for(i\u003d0; i\u0026lt;10; i++)\n   {\n        s \u003d s + a[i];\n   }\n\n   // Displaying result\n   printf(\"\\nSum of all elements  :  %d \",s);\n\n   getch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n   return 0;\n}\n\u003c/span\u003e\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays.html#p3\" name\u003d\"p3\"\u003e3. Program to insert element in between an array. ( INSERTION )\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main()\n{\n// Declaring variable \"i\" to iterate loop\nint i;\n\n// Declaring variable pos\u003dpostion from where we want to delete element\nint pos;\n\n// Declaring n\u003dnumber which we want to insert and \"m\" to store \"n\"\nint n,m;\n\n// Declaring and initialising array\nint a[6]\u003d{2,4,6,8,10};\n\n// Printing values in array before insertion\nprintf(\"Elements before deletion\\n\");\nfor(i\u003d0;i\u0026lt;5;i++)\n{\nprintf(\"%d \",a[i]);\n}\nprintf(\"\\n\");\n\n// Inputting position\nprintf(\"Enter the position of element for insertion : \");\nscanf(\"%d\",\u0026amp;pos);\n\n// Inputting value\nprintf(\"Enter the value which you want to insert : \");\nscanf(\"%d\",\u0026amp;n);\nm\u003dn;\n\n// Performing insertion\nfor(i\u003d5;i\u0026gt;\u003dpos-1;i--)\n{\na[i+1]\u003da[i];\n}\na[pos-1]\u003dm;\n\n// Printing elements after insertion\nprintf(\"Elements after insertion\\n\");\nfor(i\u003d0;i\u0026lt;6;i++)\n{\nprintf(\"%d \",a[i]);\n}\n\ngetch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nreturn 0;\n}\u003c/span\u003e\n\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays.html#p4\" name\u003d\"p4\"\u003e4. Program to delete element from an array. ( DELETION )\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main()\n{\n// Declaring variable \"i\" to iterate loop\nint i;\n\n// Declaring variable pos\u003dpostion from where we want to delete element\nint pos;\n\n// Declaring and initialising array\nint a[5]\u003d{2,4,6,8,10};\n\n// Printing values in array before deletion\nprintf(\"Elements before deletion\\n\");\nfor(i\u003d0;i\u0026lt;5;i++)\n{\nprintf(\"%d \",a[i]);\n}\nprintf(\"\\n\");\n\n// Inputting position\nprintf(\"Enter the position of element for deletion\\n\");\nscanf(\"%d\",\u0026amp;pos);\n\n// Performing deletion\nfor(i\u003dpos-1;i\u0026lt;5;i++)\n{\na[i]\u003da[i+1];\n}\n\n// Printing elements after deletion\nprintf(\"Elements after deletion\\n\");\nfor(i\u003d0;i\u0026lt;4;i++)\n{\nprintf(\"%d \",a[i]);\n}\n\ngetch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nreturn 0;\n}\n\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003cbr /\u003e\n\u003ca href\u003d\"http://www.comp-psyche.com/2014/01/c-programs-arrays.html#p5\" name\u003d\"p5\"\u003e5. Program to perform Transpose of a Matrix\u003c/a\u003e\u003cbr /\u003e\n\u003cdiv class\u003d\"mokcode\"\u003e\u003cpre\u003e\u003cspan style\u003d\"color: blue;\"\u003e#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nint main()\n{\n\n// Declaring variable i,j to iterate loop \nint i,j;\n\n// Declaring variable a to store matrix element\nint a[2][2];\n\n// Inserting element in Matrix\nprintf(\"Enter 2X2 matrix\\n\");\nfor(i\u003d0;i\u0026lt;2;i++)\n{\nfor(j\u003d0;j\u0026lt;2;j++)\n{\nscanf(\"%d\",\u0026amp;a[i][j]);\n}\n}\n\n// Displaying Matrix\nfor(i\u003d0;i\u0026lt;2;i++)\n{\n printf(\"\\n\");\n for(j\u003d0;j\u0026lt;2;j++)\n {\n  printf(\"%d \",a[i][j]);\n }\n}\n\n// Performing transpose of Matrix and displaying transposed Matrix\nprintf(\"\\n\");\nprintf(\"Transpose of matrix is \\n\");\nfor(i\u003d0;i\u0026lt;2;i++)\n{\nprintf(\"\\n\");\nfor(j\u003d0;j\u0026lt;2;j++)\n{\nprintf(\"%d \",a[j][i]);\n}\n}\n\ngetch(); \u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e// Linux user - Remove this\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\n\u003c/span\u003e\u003cspan style\u003d\"color: blue;\"\u003e\nreturn 0;\n}\u003c/span\u003e\n\u003c/pre\u003e\u003c/div\u003e\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/1870062262272059193/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-arrays.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/1870062262272059193"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/1870062262272059193"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2014/01/c-programs-arrays.html","title":"C PROGRAMS : ARRAYS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-1749873683105783588"},"published":{"$t":"2013-11-26T00:36:00.001-08:00"},"updated":{"$t":"2014-04-16T01:12:59.608-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"Common Programming Error"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Learn C"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Array"}],"title":{"type":"text","$t":"COMMON PROGRAMMING ERRORS - ARRAY"},"content":{"type":"html","$t":"\u003cdiv dir\u003d\"ltr\" style\u003d\"text-align: left;\" trbidi\u003d\"on\"\u003e\u003ctitle\u003eCOMMON PROGRAMMING ERRORS - ARRAY\u003c/title\u003e\u003cbr /\u003e\n\u003cdiv style\u003d\"text-align: left;\"\u003e\u003c/div\u003e\u003cdiv style\u003d\"text-align: left;\"\u003e\u003c/div\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003eDeclaring an array \u003cspan style\u003d\"color: lime;\"\u003ewithout specifying any value\u003c/span\u003e as size of array.\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003eDeclaring an array taking \u003cspan style\u003d\"color: lime;\"\u003evariable n\u003c/span\u003e as size of array. \u003cspan style\u003d\"color: lime;\"\u003eC\u003c/span\u003e does not allow a \u003cspan style\u003d\"color: lime;\"\u003evariable length array.\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003eInitializing \u003cspan style\u003d\"color: lime;\"\u003emore values\u003c/span\u003e than the \u003cspan style\u003d\"color: lime;\"\u003especified size.\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003eAccessing array elements \u003cspan style\u003d\"color: lime;\"\u003ebeyond the range limits.\u003c/span\u003e\u0026nbsp;\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003eArray elements are to be used from \u003cspan style\u003d\"color: lime;\"\u003e0 to maxsize-1.\u0026nbsp;\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003e\u003cspan style\u003d\"color: lime;\"\u003eC\u003c/span\u003e does not report any error if user tries to access elements beyond this range but some \u003cspan style\u003d\"color: lime;\"\u003egarbage value is printed.\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003cul style\u003d\"text-align: left;\"\u003e\u003cli style\u003d\"text-align: justify;\"\u003eDeclaring array of \u003cspan style\u003d\"color: lime;\"\u003etype void.\u003c/span\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003cdiv style\u003d\"text-align: justify;\"\u003e\u003cdiv\u003e\u003cspan style\u003d\"color: yellow;\"\u003eMore Informative Posts:\u003c/span\u003e\u003c/div\u003e\u003cdiv\u003e\u003cul\u003e\u003cli\u003e\u003cspan style\u003d\"color: yellow;\"\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/learn-C.html\"\u003eComplete List Of Learn C\u003c/a\u003e\u003c/span\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-error-complete-list.html\"\u003eCommon Programming Error - Complete List\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-errors-string.html\"\u003eCommon Programming Error - String\u003c/a\u003e\u003c/li\u003e\n\u003cli\u003e\u003ca href\u003d\"http://www.comp-psyche.com/2013/11/common-programming-errors-pointers.html\"\u003eCommon Programming Error - Pointers\u003c/a\u003e\u003c/li\u003e\n\u003c/ul\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https://www.comp-psyche.com/feeds/1749873683105783588/comments/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https://www.comp-psyche.com/2013/11/common-programming-errors-array.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/1749873683105783588"},{"rel":"self","type":"application/atom+xml","href":"https://www.blogger.com/feeds/8285804830535272268/posts/default/1749873683105783588"},{"rel":"alternate","type":"text/html","href":"https://www.comp-psyche.com/2013/11/common-programming-errors-array.html","title":"COMMON PROGRAMMING ERRORS - ARRAY"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"https://www.blogger.com/profile/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"35","height":"35","src":"//www.blogger.com/img/blogger_logo_round_35.png"}}],"thr$total":{"$t":"0"}}]}});