// API callback
relpostimgcuplik({"version":"1.0","encoding":"UTF-8","feed":{"xmlns":"http://www.w3.org/2005/Atom","xmlns$openSearch":"http://a9.com/-/spec/opensearchrss/1.0/","xmlns$blogger":"http://schemas.google.com/blogger/2008","xmlns$georss":"http://www.georss.org/georss","xmlns$gd":"http://schemas.google.com/g/2005","xmlns$thr":"http://purl.org/syndication/thread/1.0","id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268"},"updated":{"$t":"2023-07-30T02:11:08.392-07:00"},"category":[{"term":"C Programs"},{"term":"Learn C"},{"term":"Common Programming Error"},{"term":"searching and sorting"},{"term":"control sturctures"},{"term":"Fundamental"},{"term":"List of C Programs"},{"term":"string"},{"term":"Array"},{"term":"Pattern"},{"term":"Contents"},{"term":"Pointers"},{"term":"functions"},{"term":"Dynamic memory allcation"},{"term":"recursion"},{"term":"C Turbo Compiler"},{"term":"File Handling"},{"term":"Structures"}],"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.comp-psyche.com\/feeds\/posts\/default"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/-\/C+Programs?alt=json-in-script\u0026max-results=50"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/search\/label\/C%20Programs"},{"rel":"hub","href":"http://pubsubhubbub.appspot.com/"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"generator":{"version":"7.00","uri":"http://www.blogger.com","$t":"Blogger"},"openSearch$totalResults":{"$t":"31"},"openSearch$startIndex":{"$t":"1"},"openSearch$itemsPerPage":{"$t":"50"},"entry":[{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-4120851131041148268"},"published":{"$t":"2014-02-02T03:06:00.000-08:00"},"updated":{"$t":"2014-07-15T20:46:52.038-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Pattern"}],"title":{"type":"text","$t":"C PROGRAM : PATTERN"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ctitle\u003EC PROGRAMS : PATTERN\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#p16\" name=\"p16\"\u003E16. Program to print the given pattern \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given Pattern\n\n\/*\n\n1  \n2 6 \n3 7 10\n4 8 11 13\n5 9 12 14 15 ... till n rows\n\n*\/\n\n\/* \n\nFor example :\n\nFor n=3\n\n1\n2 4\n3 5 6\n\nFor n=6\n\n1  \n2 7 \n3 8 12\n4 9 13 16 \n5 10 14 17 19\n6 11 15 18 20 21\n\n*\/\n\n#include \u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n int main()\n  { \n  \/\/ Declaring variable i, j to iterate loop\n int i, j;    \n \n \/\/ Declaring variable n = maximum rows \n int n;\n \n \/\/Declaring variable k and num to help in generating \"values\"\n int k, num=1; \n \n \/\/ Inputting Number of rows\n printf(\"Enter number of rows : \");\n  scanf(\"%d\",\u0026amp;n);\n \n  \/\/ Running loop for rows\n  for (i=1; i\u0026lt;=n ; i++) \n  {\n     num=i;\n     k=n-1;\n  \n   \/\/ printing values\n  for (j=1; j\u0026lt;=i; j++) \n      {\n       \/\/ %-4d = reserves 4 spaces for printing \"value\" to obtain clarity in pattern\n printf(\"%-4d\",num);\n        num=num+k;\n        k=k-1;    \n      } \n      \n   printf(\"\\n\");    \n }\n        \n     getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n     return 0; \n  }\u003C\/span\u003E \n\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#p17\" name=\"p17\"\u003E17. Program to print the given pattern \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print pattern : Hollow Diamond\n\n\/* \n\n******** ********\n*******   *******\n******     ****** \n*****       *****\n****         ****\n***           ***\n**             **\n*               *\n\n*               *\n**             **\n***           ***\n****         ****\n*****       ***** \n******     ******\n*******   *******\n******** ********\n\nLOGIC :\n\nBREAKING IT UP : It has 2 parts\n\nFirst part :\n\n******** ********\n*******   *******\n******     ****** \n*****       *****\n****         ****\n***           ***\n**             **\n*               *\n\nWhich is further divided into : \n\nFirst Sub Part :\n\n********\n*******\n******\n*****\n****\n***\n**\n* \n\nSecond Sub part :\n\n******** \n ******* \n  ****** \n   *****  \n    ****             \n     ***               \n      **\n       *\n       \nAnd ofcourse the spaces before it.\n\nSecond Part :\n\n*               *\n**             **\n***           ***\n****         ****\n*****       ***** \n******     ******\n*******   *******\n******** ********\n\nWhich is further divided into :\n\nFirst Sub Part :\n\n*       \n**      \n***     \n****    \n*****   \n******  \n******* \n********\n\nSecond Sub Part :\n\n       *       \n      **      \n     ***     \n    ****    \n   *****   \n  ******  \n ******* \n******** \n\nAnd the spaces before it.\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable i, j, s to iterate loop \n int i, j, s;\n \n \/\/ Declaring ms = maximum space\n int ms = 1;\n \n \/\/ Running loop for rows for first part\n for(i=1;i\u0026lt;=8;i++)\n {\n  \/\/ Printing first Sub Part :\n  for(j=8;j\u0026gt;=i;j--)\n  {\n   printf(\"*\");\n  }\n  \n  \/\/ Printing spaces\n  for(s=1;s\u0026lt;=ms;s++)\n  {\n   printf(\" \");\n  }\n  \/\/ Incresing spaces\n  ms=ms+2;\n  \n  \/\/ Printing Second Sub Part :\n  for(j=8;j\u0026gt;=i;j--)\n  {\n   printf(\"*\");\n  }\n  \n  printf(\"\\n\");\n  \n }\n \n printf(\"\\n\");\n \/\/ Initialising ms = 15 i.e the maximum space\n ms = 15;\n \n\/\/ Running loop for Second Part\n for(i=1;i\u0026lt;=8;i++)\n {\n  \/\/ Printing first Sub Part :\n  for(j=1;j\u0026lt;=i;j++)\n  {\n   printf(\"*\");\n  }\n  \n  \/\/ Printing spaces\n  for(s=1;s\u0026lt;=ms;s++)\n  {\n   printf(\" \");\n  }\n  \/\/ Reducing spaces\n  ms=ms-2;\n  \n  \/\/ Printing Second Sub Part :\n  for(j=1;j\u0026lt;=i;j++)\n  {\n   printf(\"*\");\n  }\n  \n  printf(\"\\n\");\n  \n }\n\n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#p18\" name=\"p18\"\u003E18. Program to print the given pattern \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\n\n      *\n     ***\n    *****\n   *******\n  *********\n   *******  \n    *****\n     ***\n      * \n\nBREAKING IT UP : The above pattern has two parts\n\nFirst Part :\n\n      *\n     ***\n    *****\n   *******\n  *********\n\nSecond Part :\n\n   *******  \n    *****\n     ***\n      * \n\n *\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable i, j, s to iterate loop\n    int i,j,s;\n    \n    \/\/ Declaring variable ms = maximum space\n    int ms = 5;\n    \n    \/\/ Declaring variable to print \"*\" ( asterik )\n    int as = 1;\n    \n    \/\/ Running loop for First part\n    for(i=1;i\u0026lt;=5;i++)\n    {\n     \/\/ Printing Space\n     for(s=1;s\u0026lt;=ms;s++)\n     {\n      printf(\" \");\n     }\n     \n     \/\/ Reducing spaces\n     ms--;\n     \n     \/\/ Printing First Part\n     for(j=1;j\u0026lt;=as;j++)\n     {\n      printf(\"*\");\n     }\n     \n     \/\/ Increasing Asterik ( \"*\" )\n     as=as+2;\n     \n     printf(\"\\n\");\n    }\n    \n \/\/ Re-initialising ms = maximum space and aterik\n ms=2;\n as=7;\n \n    \/\/ Running loop for Second Part\n     for(i=1;i\u0026lt;=5;i++)\n    {\n     \/\/ Printing Space\n     for(s=1;s\u0026lt;=ms;s++)\n     {\n      printf(\" \");\n     }\n     \n     \/\/ Increasing spaces\n     ms++;\n     \n     \/\/ Printing First Part\n     for(j=1;j\u0026lt;=as;j++)\n     {\n      printf(\"*\");\n     }\n     \n     \/\/ Decreasing Asterik ( \"*\" )\n     as=as-2;\n     \n     printf(\"\\n\");\n    }\n    \ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#p19\" name=\"p19\"\u003E19. Program to print the given pattern \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\n\n8 4 2 1\n4 2 1\n2 1\n1\n\n *\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt;\nint main()\n{\n int n=8,m;\n int i,j;\n m=n;\n \n for(i=4;i\u0026gt;=1;i--)\n {\n  for(j=1;j\u0026lt;=i;j++)\n  {\n   printf(\"%d \",m);\n   m=m\/2; \n  }\n  m=n\/2;\n  n=n\/2;\n  printf(\"\\n\");\n }\n \n getch();\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#p20\" name=\"p20\"\u003E20. Program to print the given pattern \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n        int arr[30],temp[30],i,j,k,l,n;\n     \n       printf(\"Enter the number of lines to be printed: \");\n       scanf(\"%d\",\u0026amp;n);\n\n       temp[0]=1;\n       arr[0]=1;\n\n       for(j=0;j\u0026lt;n;j++)\n       printf(\" \");\n\n       printf(\" 1\\n\");\n\n       for(i=1;i\u0026lt;n;i++)\n       {\n               for(j=0;j\u0026lt;n-i;j++)\n       printf(\" \");\n\n       for(k=1;k\u0026lt;i;k++)\n       {\n                  arr[k]=temp[k-1]+temp[k];      \n        }\n\n                arr[i]=1;\n\n                for(l=0;l\u0026lt;=i;l++)\n       {\n                 printf(\"%2d\",arr[l]);\n                 temp[l]=arr[l];\n        }\n\n\n                printf(\"\\n\");\n        }\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n\n}\n\u003C\/span\u003E\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"color: yellow;\"\u003EMore Informative posts :\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cul\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html\"\u003EC Programs Pattern ( 1-5 )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html\"\u003EC Programs Pattern ( 6-10 )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html\"\u003EC Programs Pattern ( 11-16 )\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\n\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/4120851131041148268\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/4120851131041148268"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/4120851131041148268"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html","title":"C PROGRAM : PATTERN"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-567350625665758846"},"published":{"$t":"2014-02-02T02:54:00.000-08:00"},"updated":{"$t":"2014-07-15T20:47:05.108-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Pattern"}],"title":{"type":"text","$t":"C PROGRAM : PATTERN"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ctitle\u003EC PROGRAMS : PATTERN\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p11\" name=\"p11\"\u003E11. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n        5\n      4 5\n    3 4 5\n  2 3 4 5\n1 2 3 4 5\n\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nSimplifying the pattern :\n\n--------5\n------4 5\n----3 4 5 \n--2 3 4 5\n1 2 3 4 5\n\nHere ( - ) indicates space before \"value\" to be printed.\ni.e -- indicates two space, ---- indicates four space and so on.\n\nThe above patter is similar to patern:\n5\n4 5\n3 4 5 \n2 3 4 5\n1 2 3 4 5\n\nThe only difference is we print spaces before the \"values\". \nSo design logic according to this and print spaces before that.\nIts as simple as you like.\n\nConsider the diagonal to be rows and a single line to be column.\n\nNow earlier we worked only on rows and columns without spaces before the printed \"value\" \nbut now we have spcaes as well.\nSo we include another loop for spaces.\n\nNumber of loops required = 3 \n( since we have rows and columns and also spaces. 1 loop for row and 1 loop for column \nand 1 loop for spaces.)\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns. \nOne more inner loop will be for printing space.\n\nAbove pattern is different from the pattern we have been printing.\nNotice the diagonal values are all same ( i.e 5 - neither increasing nor decreasing ) and\nAlso the initial column value is changing. So what do we do????\n\nSimple, Since diagonal values are all same ( i.e 5 - neither increasing nor decreasing ) \nso we consider ( 5 4 3 2 1 ) as diagonal values.\nSo, we run \"i\" loop i.e the outer loop from 5 to 1 \nas the diagonal values are in decreasing order according to our assumption.\n\nAlso if you notice the single line value( i.e column value ) is in increasing order \nthe only catch is this time the initial \"value\" is changing and the last \"value\" is fixed. \nEarlier it was just the reverse of it.\nSo, now we run \"j\" loop i.e the inner loop from \"i\" to 5 as last value is always 5.\n\nNow For spaces : If you notice the spaces are in decreasing manner \n( i.e 8 spaces, 6 spaces, 4 spaces, 2 spaces and then none )\nWe can print the spaces by utilising \"i\" value \nbut to simplify the pattern and make it easier we use another value m=8 and \nreduce it by 2 after the completion of loop for spaces.\ni.e We run the inner loop \"s\" from 1 to m.\n\nWe print \"value\" in the inner loop \nsince number of columns = number of \"value\" to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n\/\/ Declaring variable i, j, s to iterate outer and inner loop respectively\n\/\/ we are using \"i\" for rows, \"j\" for columns ans \"s\" for spaces.\nint i, j, s;\n \n\/\/ Initialising m = 8 as maximum number of space = 8\nint m = 8;\n \n\/* Since we have five rows so we iterate the \"i\" loop from 5 to 1 ( i.e 5 times )\nWe run the \"i\" loop in decreasing order ( i.e from 5 to 1 ) \nsince rows is in increasing order(5 4 3 2 1 diagnol value - according to our assumption of diagonal values ) *\/\nfor(i=5;i\u0026gt;=1;i--)\n{\n\/\/ Printing spaces\nfor(s=1;s\u0026lt;=m;s++)\n{\nprintf(\" \");\n}\n\/\/ Reducing value of \"m\" by 2 to reduce spaces\nm=m-2;\n  \n\/* Notice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nwe run the \"j\" loop in increasing order ( i.e from i to 5 ) since column is in increasing order. *\/\n  \nfor(j=i;j\u0026lt;=5;j++)\n{\n\/\/ Printing \"value\" in the inner loop since number of columns = number of \"value\" to be printed.\n\/* Here we print the value of \"j\" since value to be printed is the position of the column according to initialisation in loop. *\/\n\nprintf(\"%d \",j);\n}\n  \n\/\/ After completion of printing \"value\" in row we need to go to the next row.\nprintf(\"\\n\");\n}\n \ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p12\" name=\"p12\"\u003E12. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ NOTE : For Better understanding read both LOGIC and COMMENTS\n\n\/\/ Program to print the given patter :\n\n\/* \n\n1\n* *\n1 2 3\n* * * *\n1 2 3 4 5 .... till n rows\n\nHere n = any integer value entered by user.\n  n represents rows.\n\nExample :\n\nFor n=2\n\n1\n* *\n\nFor n=6\n\n1\n* *\n1 2 3\n* * * *\n1 2 3 4 5 \n* * * * * *\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nIn above Pattern Number of rows = n\n\nConsider the diagonal to be rows and a single line to be column.\n\nNumber of loops required = 2 \n( since we have rows and columns. 1 loop for row and 1 loop for column. )\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns.\nouter loop \"i\" runs from 1 to n since we have n rows.\nWe run the \"i\" loop in increasing order ( i.e from 1 to n )\nsince rows is in increasing order(1 3  5 ... n diagnol value)\n\nNotice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nso we run the \"j\" loop i.e the inner loop from 1 to \"i\".\nWe run the \"j\" loop in increasing order ( i.e from 1 to i ) \nsince column is in increasing order ( 1 2 3 ... i single line value )\n\nNow every time row%2 == 0 we print \"*\" instead of the regular values.\n\nWe print \"value\" in the inner loop \nsince number of columns = number of \"values\" to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n\/\/ Declaring variable i,j to iterate outer and inner loop respectively\n\/\/ we are using \"i\" for rows and \"j\" for columns\nint i,j;\n \n\/\/Declaring Variale n=rows\nint n;\n \n\/\/ Entering number of rows from user\nprintf(\"Enter number of rows : \");\nscanf(\"%d\",\u0026amp;n);\n \n\/\/ Since we have five rows so we iterate the \"i\" loop from 1 to 5 ( i.e 5 times )\nfor(i=1;i\u0026lt;=n;i++)\n{\n\/* Notice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nso we run the \"j\" loop from 1 to \"i\" *\/\n   \nfor(j=1;j\u0026lt;=i;j++)\n{\n\/* Printing \"value\" in the inner loop \nsince number of columns = number of \"value\" to be printed. *\/\n  \nif(i%2==0)\nprintf(\"* \");\nelse\nprintf(\"%d \",j);\n}\n  \n\/\/ After completion of printing \"value\" in row we need to go to the next row. \nprintf(\"\\n\");\n}\n \ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p13\" name=\"p13\"\u003E13. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n\n1                 1\n1 2             1 2\n1 2 3         1 2 3\n1 2 3 4     1 2 3 4\n1 2 3 4 5 1 2 3 4 5\n\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nSimplifying the pattern :\n\nWe break the pattern in parts : In this case in three parts.\n\nFirst part :\n1\n1 2\n1 2 3\n1 2 3 4 \n1 2 3 4 5\n\nSecond part : It is actually the spaces that we print before the third part.\n----------------\n  ------------\n    --------\n      ----  \n      \nHere ( - ) indicates space before \"value\" to be printed.\ni.e -- indicates two space, ---- indicates four space and so on.\n\nThird part :\n        1\n      1 2\n    1 2 3\n  1 2 3 4\n1 2 3 4 5\n\nThe above patter ( i.e the third part ) is similar to patern:\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n\nThe only difference is we print spaces before the \"values\". \nSo design logic according to this and print spaces before that.\nI am referring to the second part spaces. Its as simple as you like.\n\nIn earlier example I have explained enough so from now on I will not go in details.\n\nNumber of loops required = 4, one outer loop and the three inner loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/* Declaring variable i, j, k, s \n to iterate outer and the three inner loop respectively *\/\n int i, j, k, s;\n \n \/\/ Initialising ms = 16 as maximum number of space = 16\n int ms = 16;\n \n \/\/ Running loop for rows\n for(i=1;i\u0026lt;=5;i++)\n {\n  \n  \/\/ Printing the First part : \n  for(j=1;j\u0026lt;=i;j++)\n  {\n   printf(\"%d \",j);\n  }\n  \n  \/\/ Printing spaces\n  for(s=1;s\u0026lt;=ms;s++)\n  {\n   printf(\" \");\n  }\n  \/\/ Reducing value of \"m\" by 4 to reduce spaces\n  ms=ms-4;\n  \n  \/\/ Printing the third part :\n  for(k=1;k\u0026lt;=i;k++)\n  {\n   printf(\"%d \",k);\n  }\n  \n  \/* After completion of printing \"value\" in row \n  we need to go to the next row.*\/\n  printf(\"\\n\");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p14\" name=\"p14\"\u003E14. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n\n1                 1\n1 2             2 1\n1 2 3         3 2 1\n1 2 3 4     4 3 2 1\n1 2 3 4 5 5 4 3 2 1\n\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nSimplifying the pattern :\n\nWe break the pattern in parts : In this case in three parts.\n\nFirst part :\n1\n1 2\n1 2 3\n1 2 3 4 \n1 2 3 4 5\n\nSecond part : It is actually the spaces that we print before the third part.\n----------------\n  ------------\n    --------\n      ----  \n      \nHere ( - ) indicates space before \"value\" to be printed.\ni.e -- indicates two space, ---- indicates four space and so on.\n\nThird part :\n        1\n      2 1\n    3 2 1\n  4 3 2 1\n5 4 3 2 1\n\nThe above patter ( i.e the third part ) is similar to patern:\n1\n2 1\n3 2 1\n4 3 2 1\n5 4 3 2 1\n\nThe only difference is we print spaces before the \"values\". \nSo design logic according to this and print spaces before that.\nI am referring to the second part spaces. Its as simple as you like.\n\nIn earlier example I have explained enough so from now on I will not go in details.\n\nNumber of loops required = 4, one outer loop and the three inner loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/* Declaring variable i, j, k, s \n to iterate outer and thre three inner loop respectively *\/\n int i, j, k, s;\n \n \/\/ Initialising ms = 16 as maximum number of space = 16\n int ms = 16;\n \n \/\/ Running loop for rows\n for(i=1;i\u0026lt;=5;i++)\n {\n  \n  \/\/ Printing the First part : \n  for(j=1;j\u0026lt;=i;j++)\n  {\n    printf(\"%d \",j);\n  }\n  \n  \/\/ Printing spaces\n  for(s=1;s\u0026lt;=ms;s++)\n  {\n   printf(\" \");\n  }\n  \/\/ Reducing value of \"m\" by 4 to reduce spaces\n  ms=ms-4;\n  \n  \/\/ Printing the third part :\n  for(k=i;k\u0026gt;=1;k--)\n  {\n   printf(\"%d \",k);\n  }\n  \n  \/* After completion of printing \"value\" in row \n  we need to go to the next row. *\/\n  printf(\"\\n\");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p15\" name=\"p15\"\u003E15. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n\n1                 5\n1 2             5 4\n1 2 3         5 4 3\n1 2 3 4     5 4 3 2\n1 2 3 4 5 5 4 3 2 1\n\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nSimplifying the pattern :\n\nWe break the pattern in parts : In this case in three parts.\n\nFirst part :\n1\n1 2\n1 2 3\n1 2 3 4 \n1 2 3 4 5\n\nSecond part : It is actually the spaces that we print before the third part.\n----------------\n  ------------\n    --------\n      ----  \n      \nHere ( - ) indicates space before \"value\" to be printed.\ni.e -- indicates two space, ---- indicates four space and so on.\n\nThird part :\n        5\n      5 4\n    5 4 3\n  5 4 3 2\n5 4 3 2 1\n\nThe above patter ( i.e the third part ) is similar to patern:\n5\n5 4\n5 4 3\n5 4 3 2\n5 4 3 2 1\n\nThe only difference is we print spaces before the \"values\". \nSo design logic according to this and print spaces before that.\nI am referring to the second part spaces. Its as simple as you like.\n\nIn earlier example I have explained enough so from now on I will not go in details.\n\nNumber of loops required = 4, one outer loop and the three inner loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/* Declaring variable i, j, k, s \n to iterate outer and thre three inner loop respectively *\/\n int i, j, k, s;\n \n \/\/ Initialising ms = 16 as maximum number of space = 16\n int ms = 16;\n \n \/\/ Initialising variable to help print third part tp = 5\n int tp = 5;\n \n \/\/ Running loop for rows\n for(i=1;i\u0026lt;=5;i++)\n {\n  \n  \/\/ Printing the First part : \n  for(j=1;j\u0026lt;=i;j++)\n  {\n    printf(\"%d \",j);\n  }\n  \n  \/\/ Printing spaces\n  for(s=1;s\u0026lt;=ms;s++)\n  {\n   printf(\" \");\n  }\n  \/\/ Reducing value of \"m\" by 4 to reduce spaces\n  ms=ms-4;\n  \n  \/\/ Printing the third part :\n  for(k=5;k\u0026gt;=tp;k--)\n  {\n   printf(\"%d \",k);\n  }\n  \/\/Reducing value of tp = variable used to print third part\n  tp--;\n  \n  \/* After completion of printing \"value\" in row \n  we need to go to the next row. *\/\n  printf(\"\\n\");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"color: yellow;\"\u003EMore Informative posts :\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cul style=\"text-align: left;\"\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html\"\u003EC Programs Pattern ( 1-5 )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html\"\u003EC Programs Pattern ( 6-10 )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html\"\u003EC Programs Pattern ( 16-20 )\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\n\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/567350625665758846\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/567350625665758846"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/567350625665758846"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html","title":"C PROGRAM : PATTERN"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-5719397974851199886"},"published":{"$t":"2014-02-01T23:34:00.002-08:00"},"updated":{"$t":"2014-07-15T20:47:10.249-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Pattern"}],"title":{"type":"text","$t":"C PROGRAMS : PATTERN"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ctitle\u003EC PROGRAMS : PATTERN\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p6\" name=\"p6\"\u003E6. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003E\/*\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003E5\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4 3\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4 3 2\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4 3 2 1\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003E*\/\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003E\/*\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003EREMEMBER : We always design logic according to the pattern.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003ELOGIC:\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003EConsider the diagonal to be rows and a single line to be column.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003ENumber of loops required = 2\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E( since we have rows and columns. 1 loop for row and 1 loop for column. )\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003EIt would be a nested loop since Number of columns depends on Number of rows.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003EOuter loop will be for rows and inner loop will be for columns.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003Eouter loop \"i\" runs from 5 to 1 since we have 5 rows.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003EWe run the \"i\" loop in decreasing order ( i.e from 5 to 1 )\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Esince rows is in increasing order(5 4 3 ... 1 diagnol value)\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003ENotice in above pattern Number of columns = Position of rows\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Eso we run the \"j\" loop i.e the inner loop from 5 to i.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003EWe run the \"j\" loop in decreasing order ( i.e from 5 to i )\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Esince column is in decreasing order ( 5 4 ... i single line value )\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003EWe print \"value\" in the inner loop\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Esince number of columns = number of \"value\" to be printed.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003ENOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003ELastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the\u0026nbsp;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Einner loop and before closing the outer loop.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003EComments are given to make you understand the program..\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003E*\/\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;conio.h\u0026gt;\u0026nbsp;\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003Eint main()\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E{\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\/\/ Declaring variable i,j to iterate outer and inner loop respectively\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\/\/ we are using \"i\" for rows and \"j\" for columns\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Eint i,j;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003E\/* Since we have five rows but now we should also keep an eye on the pattern to be printed.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003E\u0026nbsp;Since the pattern to be printed is in descending order so we iterate the \"i\" loop from 5 to 1 ( i.e 5 times ) *\/\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Efor(i=5;i\u0026gt;=1;i--)\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E{\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\/* Notice in above pattern Number of columns = Position of rows ( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Eso we run the \"j\" loop i.e the inner loop from 5 to i. *\/\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003Efor(j=5;j\u0026gt;=i;j--)\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E{\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\/* Here we print the value of \"j\" since value to be printed is the position of the column according to initialisation in loop. *\/\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cbr \/\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003Eprintf(\"%d \",j);\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E}\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan class=\"Apple-tab-span\" style=\"white-space: pre;\"\u003E\u003Cspan style=\"color: blue;\"\u003E  \u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\/\/ After completion of printing \"value\" in row we need to go to the next row.\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Eprintf(\"\\n\");\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E}\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan class=\"Apple-tab-span\" style=\"white-space: pre;\"\u003E\u003Cspan style=\"color: blue;\"\u003E \u003C\/span\u003E\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003Egetch();\u0026nbsp;\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003Cspan class=\"Apple-tab-span\" style=\"white-space: pre;\"\u003E \u003C\/span\u003Ereturn 0;\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E}\u003C\/span\u003E\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p7\" name=\"p7\"\u003E7. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n\n1 2 3 4 5\n1 2 3 4\n1 2 3\n1 2\n1\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nConsider the diagonal to be rows and a single line to be column.\n\nNumber of loops required = 2 \n( since we have rows and columns. 1 loop for row and 1 loop for column. )\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns.\n\nouter loop \"i\" runs from 5 to 1 since we have 5 rows.\nWe run the \"i\" loop in decreasing order ( i.e from 5 to 1 ) \nsince rows is in decreasing order(5 4 3 ... 1 diagnol value)\n\nNotice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nWe run the \"j\" loop i.e the inner loop from 1 to i.\nWe run the \"j\" loop in increasing order ( i.e from 1 to i ) \nsince rows is in increasing order(1 2 3 ... i single line value)\n\nWe print \"value\" in the inner loop \nsince number of columns = number of \"value\" to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n\/\/ Declaring variable i,j to iterate outer and inner loop respectively\n\/\/ we are using \"i\" for rows and \"j\" for columns\nint i,j;\n\n\/\/ Since we have five rows so we iterate the \"i\" loop from 5 to 1 ( i.e 5 times )\n\/\/ We run the \"i\" loop in decreasing order ( i.e from 5 to 1 ) since rows is in decreasing order(5 4 3 ... 1 diagnol value)\nfor(i=5;i\u0026gt;=1;i--)\n{\n\/\/ Notice in above pattern Number of columns = Position of rows ( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\n\/\/ We run the \"j\" loop in increasing order ( i.e from 1 to i ) since rows is in increasing order(1 2 3 ... i single line value)\nfor(j=1;j\u0026lt;=i;j++)\n{\n\/* Printing \"value\" in the inner loop since number of columns = number of \"value\" to be printed.\nHere we print the value of \"j\" since value to be printed is the position of the column according to initialisation in loop. *\/\n\nprintf(\"%d \",j);\n}\n  \n\/\/ After completion of printing \"value\" in row we need to go to the next row.\nprintf(\"\\n\");\n}\n \ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003C\/pre\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003Ereturn 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p8\" name=\"p8\"\u003E8. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n\n5 4 3 2 1\n5 4 3 2\n5 4 3\n5 4\n5\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nConsider the diagonal to be rows and a single line to be column.\n\nNumber of loops required = 2 \n( since we have rows and columns. 1 loop for row and 1 loop for column.)\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns.\n\nouter loop \"i\" runs from 1 to 5 since we have 5 rows.\nWe run the \"i\" loop in increasing order \n( i.e from 1 to 5 ) since rows is in increasing order(1 2 3 4 5 diagnol value)\n\nNotice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nWe run the \"j\" loop i.e the inner loop from 1 to i.\nWe run the \"j\" loop in decreasing order ( i.e from 5 to i ) \nsince rows is in decreasing order(5 4 ... i single line value)\n\nWe print \"value\" in the inner loop \nsince number of columns = number of \"value\" to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n\/\/ Declaring variable i,j to iterate outer and inner loop respectively\n\/\/ we are using \"i\" for rows and \"j\" for columns\nint i,j;\n \n\/* Since we have five rows so we iterate the \"i\" loop from 5 to 1 ( i.e 5 times )\nWe run the \"i\" loop in decreasing order ( i.e from 5 to 1 ) \nsince rows is in decreasing order(5 4 3 ... 1 diagnol value) *\/\n \nfor(i=1;i\u0026lt;=5;i++)\n{\n\/* Notice in above pattern Number of columns = Position of rows ( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nWe run the \"j\" loop in increasing order ( i.e from 1 to i ) since rows is in increasing order(1 2 3 ... i single line value) *\/\nfor(j=5;j\u0026gt;=i;j--)\n{\n\/* Printing \"value\" in the inner loop since number of columns = number of \"value\" to be printed.\nHere we print the value of \"j\" since value to be printed is the position of the column according to initialisation in loop. *\/\n   \nprintf(\"%d \",j);\n}\n \n\/\/ After completion of printing \"value\" in row we need to go to the next row.\nprintf(\"\\n\");\n}\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p9\" name=\"p9\"\u003E9. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n        *\n      * *\n    * * *\n  * * * *\n* * * * *\n\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nSimplifying the pattern :\n\n--------*\n------* *\n----* * *\n--* * * *\n* * * * *\n\nHere ( - ) indicates space before star ( asterik ) to be printed.\ni.e -- indicates two space, ---- indicates four space and so on.\n\nThe above pattern is similar to pattern :\n*\n* *\n* * *\n* * * *\n* * * * *\n\nThe only difference is we print spaces before the \"values\". \nSo design logic according to this and print spaces before that.\nIts as simple as you like.\n\nConsider the diagonal to be rows and a single line to be column.\n\nNow earlier we worked only on rows and columns without spaces before the printed \"value\" \nbut now we have spcaes as well. So we include another loop for spaces.\n\nNumber of loops required = 3 \n( since we have rows and columns and also spaces. 1 loop for row and 1 loop for column \nand 1 loop for spaces.)\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns. \nOne more inner loop will be for printing space.\n\nouter loop \"i\" runs from 1 to 5 since we have 5 rows.\n\nNotice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nWe run the \"j\" loop i.e the inner loop from 1 to i.\n\nNow For spaces : If you notice the spaces are in decreasing manner \n( i.e 8 spaces, 6 spaces, 4 spaces, 2 spaces and then none )\nWe can print the spaces by utilising \"i\" value \nbut to simplify the pattern and make it easier we use another value m=8 and \nreduce it by 2 after the completion of loop for spaces.\ni.e We run the inner loop \"s\" from 1 to m.\n\nWe print \"value\" in the inner loop \nsince number of columns = number of \"value\" to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n\/\/ Declaring variable i, j, s to iterate outer and inner loop respectively\n\/\/ we are using \"i\" for rows, \"j\" for columns ans \"s\" for spaces.\nint i, j, s;\n \n\/\/ Initialising m = 8 as total number of space = 8\nint m = 8;\n \n\/\/ Since we have five rows so we iterate the \"i\" loop from 5 to 1 ( i.e 5 times )\nfor(i=1;i\u0026lt;=5;i++)\n{\n\/\/ Printing spaces\nfor(s=1;s\u0026lt;=m;s++)\n{\nprintf(\" \");\n}\n\/\/ Reducing value of \"m\" by 2 to reduce spaces\nm=m-2;\n  \n\/* Notice in above pattern Number of columns = Position of rows ( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on ) *\/\nfor(j=1;j\u0026lt;=i;j++)\n{\n\/\/ Printing \"value\" in the inner loop since number of columns = number of \"value\" to be printed.\nprintf(\"* \");\n}\n  \n\/\/ After completion of printing \"value\" in row we need to go to the next row.\nprintf(\"\\n\");\n}\n \ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p10\" name=\"p10\"\u003E10. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n        1\n      1 2\n    1 2 3\n  1 2 3 4\n1 2 3 4 5\n\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nSimplifying the pattern :\n\n--------1\n------1 2\n----1 2 3\n--1 2 3 4\n1 2 3 4 5\n\nHere ( - ) indicates space before \"value\" to be printed.\ni.e -- indicates two space, ---- indicates four space and so on.\n\nThe above patter is similar to patern:\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5\n\nThe only difference is we print spaces before the \"values\". \nSo design logic according to this and print spaces before that.\nIts as simple as you like.\n\nConsider the diagonal to be rows and a single line to be column.\n\nNow earlier we worked only on rows and columns without spaces before the printed \"value\" \nbut now we have spcaes as well. So we include another loop for spaces.\n\nNumber of loops required = 3 \n( since we have rows and columns and also spaces. 1 loop for row and 1 loop for column \nand 1 loop for spaces.)\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns. \nOne more inner loop will be for printing space.\n\nouter loop \"i\" runs from 1 to 5 since we have 5 rows.\nWe run the \"i\" loop in increasing order ( i.e from 1 to 5 ) \nsince rows is in increasing order(1 2 3 4 5 diagnol value)\n\nNotice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nWe run the \"j\" loop i.e the inner loop from 1 to i.\nWe run the \"j\" loop in increasing order ( i.e from 1 to i ) \nsince column is in increasing order(1 2 3 4 5 single line value)\n\nNow For spaces : If you notice the spaces are in decreasing manner \n( i.e 8 spaces, 6 spaces, 4 spaces, 2 spaces and then none )\nWe can print the spaces by utilising \"i\" value but to simplify the pattern \nand make it easier we use another value m=8 and \nreduce it by 2 after the completion of loop for spaces.\ni.e We run the inner loop \"s\" from 1 to m.\n\nWe print \"value\" in the inner loop \nsince number of columns = number of \"value\" to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n\/\/ Declaring variable i, j, s to iterate outer and inner loop respectively\n\/\/ we are using \"i\" for rows, \"j\" for columns ans \"s\" for spaces.\nint i, j, s;\n \n\/\/ Initialising m = 8 as maximum number of space = 8\nint m = 8;\n \n\/\/ Since we have five rows so we iterate the \"i\" loop from 5 to 1\n\/* We run the \"i\" loop in increasing order ( i.e from 1 to 5 ) \nsince rows is in increasing order(1 2 3 4 5 diagnol value) *\/\n\nfor(i=1;i\u0026lt;=5;i++)\n{\n\/\/ Printing spaces\nfor(s=1;s\u0026lt;=m;s++)\n{\nprintf(\" \");\n}\n\/\/ Reducing value of \"m\" by 2 to reduce spaces\nm=m-2;\n  \n\/* Notice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nWe run the \"j\" loop in increasing order ( i.e from 1 to i ) \nsince column is in increasing order(1 2 ... i single line value) *\/\n\nfor(j=1;j\u0026lt;=i;j++)\n{\n\/\/ Printing \"value\" in the inner loop since number of columns = number of \"value\" to be printed.\n\/* Here we print the value of \"j\" since value to be printed is the position of the column according to initialisation in loop. *\/\n\nprintf(\"%d \",j);\n}\n  \n\/\/ After completion of printing \"value\" in row we need to go to the next row.\nprintf(\"\\n\");\n}\n \ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"color: yellow;\"\u003EMore Informative posts :\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cul style=\"text-align: left;\"\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html\"\u003EC Programs Pattern ( 1-5 )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html\"\u003EC Programs Pattern ( 11-15 )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html\"\u003EC Programs Pattern ( 16-20 )\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\n\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/5719397974851199886\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/5719397974851199886"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/5719397974851199886"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html","title":"C PROGRAMS : PATTERN"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-7371601159561510038"},"published":{"$t":"2014-02-01T23:05:00.000-08:00"},"updated":{"$t":"2014-07-15T20:47:13.643-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Pattern"}],"title":{"type":"text","$t":"C PROGRAMS : PATTERN"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ctitle\u003EC PROGRAMS : PATTERN\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p1\" name=\"p1\"\u003E1. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/* \n\n* \n* * \n* * * \n* * * * \n* * * * * \n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nNumber of loops required = 2 \n(since we have rows and columns. 1 loop for row and 1 loop for column.)\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns.\nouter loop \"i\" runs from 1 to 5 since we have 5 rows.\n\nNotice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nso we run the \"j\" loop i.e the inner loop from 1 to \"i\".\n\nWe print \"*\" in the inner loop since number of columns = number of star to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable i,j to iterate outer and inner loop respectively\n \/\/ we are using \"i\" for rows and \"j\" for columns\n int i,j;\n \n \/\/ Since we have five rows so we iterate the \"i\" loop from 1 to 5 ( i.e 5 times )\n for(i=1;i\u0026lt;=5;i++)\n {\u003C\/span\u003E\u003C\/pre\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E    \/* Notice in above pattern Number of columns = Position of rows \n    ( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\n    so we run the \"j\" loop i.e the inner loop from 1 to \"i\". *\/\n  \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E  for(j=1;j\u0026lt;=i;j++)\n    {\n   \/\/ Printing \"*\" in the inner loop since number of columns=number of star to be printed\n   printf(\"* \");\n    }\n  \n  \/\/ After completion of printing \"*\" in row we need to go to the next row.\n  printf(\"\\n\");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p2\" name=\"p2\"\u003E2. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n\n* \n* * \n* * * \n* * * * \n* * * * * \n* * * * * * ..... till n rows\n\nHere n = any integer value entered by user.\n  n represents rows.\n  \nExample : \n\nFor n=3\n\n*\n* * \n* * *\n\nFor n=5\n\n* \n* * \n* * *\n* * * *\n* * * * * \n\n*\/\n\n\/*\n\nREMEMBER : We always design logic according to the pattern. \n\nLOGIC:\n\nIn above Pattern Number of rows = n\n\nNumber of loops required = 2 \n( since we have rows and columns. 1 loop for row and 1 loop for column. )\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns.\nouter loop \"i\" runs from 1 to n since we have n rows.\n\nNotice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nso we run the \"j\" loop i.e the inner loop from 1 to \"i\".\n\nWe print \"*\" in the inner loop since number of columns = number of star to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable i,j to iterate outer and inner loop respectively\n \/\/ we are using \"i\" for rows and \"j\" for columns\n int i,j;\n \n \/\/Declaring Variale n=rows\n int n;\n \n \/\/ Entering number of rows from user\n printf(\"Enter number of rows : \");\n scanf(\"%d\",\u0026amp;n);\n \n \/\/ Since we have \"n\" number of  rows so we iterate the \"i\" loop from 1 to n\n for(i=1;i\u0026lt;=n;i++)\n {\n  \/* Notice in above pattern Number of columns = Position of rows \n  ( i.e 1st row has 1 column, 2nd row has 2 column and so on )\n   so we run the \"j\" loop i.e the inner loop from 1 to \"i\". *\/\n  for(j=1;j\u0026lt;=i;j++)\n  {\n   \/* Printing \"*\" in the inner loop \n   since number of columns = number of star to be printed. *\/\n   printf(\"* \");\n  }\n  \n  \/\/ After completion of one row we need to go to the next line.\n  printf(\"\\n\");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p3\" name=\"p3\"\u003E3. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ NOTE : For Better understanding read both LOGIC and COMMENTS\n\n\/\/ Program to print the given patter :\n\n\/* \n\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5 .... till n rows\n\nHere n = any integer value entered by user.\n  n represents rows.\n\nExample :\n\nFor n=2\n\n1\n1 2\n\nFor n=6\n\n1\n1 2\n1 2 3\n1 2 3 4\n1 2 3 4 5 \n1 2 3 4 5 6\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nIn above Pattern Number of rows = n\n\nConsider the diagonal to be rows and a single line to be column.\n\nNumber of loops required = 2 \n( since we have rows and columns. 1 loop for row and 1 loop for column. )\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns.\nouter loop \"i\" runs from 1 to n since we have n rows.\nWe run the \"i\" loop in increasing order ( i.e from 1 to n ) \nsince rows is in increasing order(1 2 3 ... n diagnol value)\n\n\nNotice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nso we run the \"j\" loop i.e the inner loop from 1 to \"i\".\nWe run the \"j\" loop in increasing order ( i.e from 1 to i ) \nsince column is in increasing order ( 1 2 3 ... i single line value )\n\nWe print \"value\" in the inner loop since number of columns = number of \"values\" to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable i,j to iterate outer and inner loop respectively\n \/\/ we are using \"i\" for rows and \"j\" for columns\n int i,j;\n \n \/\/Declaring Variale n=rows\n int n;\n \n \/\/ Entering number of rows from user\n printf(\"Enter number of rows : \");\n scanf(\"%d\",\u0026amp;n);\n \n \/\/ Since we have five rows so we iterate the \"i\" loop from 1 to 5\n for(i=1;i\u0026lt;=n;i++)\n {\n  \/* Notice in above pattern Number of columns = Position of rows \n  ( i.e 1st row has 1 column, 2nd row has 2 column and so on )\n   so we run the \"j\" loop from 1 to \"i\" *\/\n  for(j=1;j\u0026lt;=i;j++)\n  {\n   \/* Printing \"value\" in the inner loop \n   since number of columns=number of \"value\" to be printed.\n   Here we print the value of \"j\" \n   since value to be printed is the position of the column. *\/\n   printf(\"%d \",j);\n  }\n  \n  \/* After completion of printing \"value\" in row\n   we need to go to the next row. *\/\n  printf(\"\\n\");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p4\" name=\"p4\"\u003E4. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n\n1\n2 2\n3 3 3\n4 4 4 4\n5 5 5 5 5 .... till n rows\n\nHere n = any integer value entered by user.\n  n represents rows.\n\nExample :\n\nFor n=3\n\n1\n2 2\n3 3 3\n\nFor n=6\n\n1\n2 2 \n3 3 3 \n4 4 4 4\n5 5 5 5 5\n6 6 6 6 6 6\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nIn above Pattern Number of rows = n\n\nNumber of loops required = 2 \n( since we have rows and columns. 1 loop for row and 1 loop for column. )\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns.\nouter loop \"i\" runs from 1 to n since we have n rows.\n\nNotice in above pattern Number of columns = Position of rows \n( i.e 1st row has 1 column, 2nd row has 2 column, 3rd row has 3 columns and so on )\nso we run the \"j\" loop i.e the inner loop from 1 to \"i\".\n\nWe print \"value\" in the inner loop \nsince number of columns = number of \"values\" to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable i,j to iterate outer and inner loop respectively\n \/\/ we are using \"i\" for rows and \"j\" for columns\n int i,j;\n \n \/\/Declaring Variale n=rows\n int n;\n \n \/\/ Entering number of rows from user\n printf(\"Enter number of rows : \");\n scanf(\"%d\",\u0026amp;n);\n \n \/\/ Since we have five rows so we iterate the \"i\" loop from 1 to 5\n for(i=1;i\u0026lt;=n;i++)\n {\n  \/* Notice in above pattern Number of columns = Position of rows \n  ( i.e 1st row has 1 column, 2nd row has 2 column and so on )\n   so we run the \"j\" loop from 1 to \"i\" *\/\n   \n  for(j=1;j\u0026lt;=i;j++)\n  {\n   \/* Printing \"value\" in the inner loop \n   since number of columns = number of \"value\" to be printed.\n   Here we print the value of \"i\" \n   since value to be printed is the position of the row. *\/\n   \n   printf(\"%d \",i);\n  }\n  \n  \/* After completion of printing \"value\" in row \n  we need to go to the next row. *\/\n  printf(\"\\n\");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p5\" name=\"p5\"\u003E5. Program to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Program to print the given patter :\n\n\/* \n\n1 1 1 1 1\n2 2 2 2 2\n3 3 3 3 3\n4 4 4 4 4\n5 5 5 5 5\n\n*\/\n\n\/* \n\nREMEMBER : We always design logic according to the pattern.\n\nLOGIC:\n\nNumber of loops required = 2 \n( since we have rows and columns. 1 loop for row and 1 loop for column. )\n\nIt would be a nested loop since Number of columns depends on Number of rows.\n\nOuter loop will be for rows and inner loop will be for columns.\nouter loop \"i\" runs from 1 to 5 since we have 5 rows.\n\nInner loop also runs from 1 to 5 since we have 5 columns in each row.\nso we run the \"j\" loop i.e the inner loop from 1 to 5.\n\nWe print \"value\" in the inner loop \nsince number of columns = number of \"value\" to be printed.\nNOTE : WE CAN PRINT ANYTHING WHICH WE WANT. ( for ex : printf(\"%d\",j) or printf(\"%d\",i) or anything according to pattern.\n\nLastly after one rotation (completion) of inner loop we need to go to the next line so we use printf(\"\\n\") statement after closing the \ninner loop and before closing the outer loop.\n\nComments are given to make you understand the program..\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable i,j to iterate outer and inner loop respectively\n \/\/ we are using \"i\" for rows and \"j\" for columns\n int i,j;\n \n \/\/ Since we have five rows so we iterate the \"i\" loop from 1 to 5\n for(i=1;i\u0026lt;=5;i++)\n {\n  \/\/ We have five columns as well so we iterate the \"j\" loop from 1 to 5.\n  for(j=1;j\u0026lt;=5;j++)\n  {\n   \/* Printing \"value\" in the inner loop \n   since number of columns = number of \"value\" to be printed.\n   Here we print the value of \"i\" \n   since value to be printed is the position of the row. *\/\n   \n   printf(\"%d \",i);\n  }\n  \n  \/* After completion of printing \"*\" in row \n  we need to go to the next row. *\/\n  \n  printf(\"\\n\");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Cspan style=\"color: yellow;\"\u003EMore Informative posts : \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003Cul style=\"text-align: left;\"\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html\"\u003EC Programs Pattern ( 6-10 )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html\"\u003EC Programs Pattern ( 11-15 )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html\"\u003EC Programs Pattern ( 16-20 )\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\n\u003Cdiv\u003E\n\u003Cspan style=\"color: yellow;\"\u003EOther References :\u0026nbsp;\u003C\/span\u003E\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Cul style=\"text-align: left;\"\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.programmingspark.com\/search\/label\/Pattern%20Programming%20in%20C\"\u003ELearn Pattern Programming in C\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/7371601159561510038\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/7371601159561510038"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/7371601159561510038"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html","title":"C PROGRAMS : PATTERN"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-4467890176216028238"},"published":{"$t":"2014-01-29T07:55:00.000-08:00"},"updated":{"$t":"2014-04-16T01:02:14.560-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Dynamic memory allcation"}],"title":{"type":"text","$t":"C PROGRAMS : DYNAMIC MEMORY ALLOCATION"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : DYNAMIC MEMORY ALLOCATION\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html#p5\" name=\"p5\"\u003E5. Program to find the sum of \"n\" elements\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdlib.h\u0026gt;\n\nint main()\n{\n    int *ptr,n,i, sum=0;\n    \n    printf(\"Enter number of elements : \");\n    scanf(\"%d\",\u0026amp;n);\n    \n    \/\/ Allocating memory dynamically\n    ptr=(int *)malloc(n*sizeof(int));\n    \n    \/\/ Inputing elements\n    printf(\"Enter Elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n       scanf(\"%d\",(ptr+i));\n    }\n    \n    \/\/ Calculating sum\n   for(i=0;i\u0026lt;n;i++)\n    {\n     sum = sum + *(ptr+i);\n    }  \n    \n    \/\/ Displaying elements\n    printf(\"Entered elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    printf(\"%d \",*(ptr+i));\n    }\n \n    \/\/ Displaying sum\n    printf(\"\\nSum of elements : %d\",sum);\n\n    \/\/ Deallocating memory\n    free(ptr);\n \n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\n\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html#p6\" name=\"p6\"\u003E6. Program to sort \"n\" elements in ascending order \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdlib.h\u0026gt;\n\nint main()\n{\n    int *ptr,n,i,j, temp;\n    \n    printf(\"Enter number of elements : \");\n    scanf(\"%d\",\u0026amp;n);\n    \n    \/\/ Allocating memory dynamically\n    ptr=(int *)malloc(n*sizeof(int));\n    \n    \/\/ Inputing elements\n    printf(\"Enter Elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n       scanf(\"%d\",(ptr+i));\n    }\n    \n    \/\/ Displaying elements\n    printf(\"Entered elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n       printf(\"%d \",*(ptr+i));\n    }\n \n    \/\/ Sorting elements\n   for(i=0;i\u0026lt;n;i++)\n        {\n     for(j=i+1;j\u0026lt;n;j++)\n     {\n      if( *(ptr+i) \u0026gt; *(ptr+j) )\n      {\n       temp=*(ptr+i);\n       *(ptr+i)=*(ptr+j);\n       *(ptr+j)=temp;\n      }\n     }\n  }  \n    \n \n \/\/ Displaying sorted elements\n printf(\"\\nElements sorted in ascending order : \");\n for(i=0;i\u0026lt;n;i++)\n        {\n        printf(\"%d \",*(ptr+i));\n }\n \n \/\/ Deallocating memory\n free(ptr);\n \n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\u003C\/span\u003E\n}\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html#p7\" name=\"p7\"\u003E7.  Program to search an element \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdlib.h\u0026gt;\n\nint main()\n{\n    int *ptr,n,i, sum=0;\n    \n    \/\/Declaring variable es=element to be searched, flag=indicates if element found or not\n    int es, flag=0;\n    \n    printf(\"Enter number of elements : \");\n    scanf(\"%d\",\u0026amp;n);\n    \n    \/\/ Allocating memory dynamically\n    ptr=(int *)malloc(n*sizeof(int));\n    \n    \/\/ Inputing elements\n    printf(\"Enter Elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    scanf(\"%d\",(ptr+i));\n }\n    \n    \/\/ Displaying elements\n    printf(\"Entered elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    printf(\"%d \",*(ptr+i));\n }\n \n    \/\/ Inputing element to be searched\n    printf(\"\\nEnter element to be searched : \");\n    scanf(\"%d\",\u0026amp;es);\n    \n    \/\/ Searching element\n   for(i=0;i\u0026lt;n;i++)\n    {\n     if( *(ptr+i)==es)\n     {\n      flag=1;\n      break;\n     }\n }  \n \n \/\/ Displaying element searched or not\n if(flag==1)\n printf(\"Element found \");\n \n else\n printf(\"Element not found \");\n \n \/\/ Deallocating memory\n free(ptr);\n \n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html#p8\" name=\"p8\"\u003E8. Program to enter three strings and sort them in ascending order alphabetically\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdlib.h\u0026gt;\n#include\u0026lt;string.h\u0026gt;\nint main()\n{\n int i,j;\n \n \/\/ Declaring variable temp=tempeorary helps in swapping strings\n char temp[50];\n \n \/\/ Here 3 = number of string which we can enter\n char *p1[3];\n\n \/\/ Inputing string\n printf(\"Enter three strings : \");\n for(i=0;i\u0026lt;3;i++)\n {\n  p1[i]=(char *)malloc(12*sizeof(char));\n  gets(p1[i]);\n }\n \n \/\/ Performing sorting\n for(i=0;i\u0026lt;3;i++)\n {\n  for(j=i+1;j\u0026lt;3;j++)\n  {\n   \/\/ swapping strings\n   if(strcmp(p1[i],p1[j])\u0026gt;0)\n   {\n    strcpy(temp,p1[i]);\n    strcpy(p1[i],p1[j]);\n    strcpy(p1[j],temp);\n   }\n  }\n }\n \n \/\/ Displaying sorted string\n printf(\"Sorted string : \\n\");\n for(i=0;i\u0026lt;3;i++)\n puts(p1[i]);\n\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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\/4467890176216028238\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/4467890176216028238"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/4467890176216028238"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html","title":"C PROGRAMS : DYNAMIC MEMORY ALLOCATION"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-6914796806847001338"},"published":{"$t":"2014-01-29T07:45:00.000-08:00"},"updated":{"$t":"2014-04-16T01:02:28.080-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Dynamic memory allcation"}],"title":{"type":"text","$t":"C PROGRAMS : DYNAMIC MEMORY ALLOCATION"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : DYNAMIC MEMORY ALLOCATION\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html#p1\" name=\"p1\"\u003E1. Program to dynamically allocate memory using calloc for \"n\" integer elements, input elements, display it and then free the memory\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdlib.h\u0026gt;\n\nint main()\n{\n    int *ptr,n,i;\n    \n    printf(\"Enter number of elements : \");\n    scanf(\"%d\",\u0026amp;n);\n    \n    \/\/ Allocating memory dynamically\n    ptr=(int *)calloc(n,sizeof(int));\n    \n    \/\/ Inputing elements\n    printf(\"Enter Elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    scanf(\"%d\",(ptr+i));\n }\n    \n    \/\/ Displaying elements\n    printf(\"Entered elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    printf(\"%d \",*(ptr+i));\n }\n \n \/\/ Deallocating memory\n free(ptr);\n \n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html#p2\" name=\"p2\"\u003E2. Program to dynamically allocate memory using malloc for \"n\" integer elements, input elements, display it and then free the memory\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdlib.h\u0026gt;\n\nint main()\n{\n    int *ptr,n,i;\n    \n    printf(\"Enter number of elements : \");\n    scanf(\"%d\",\u0026amp;n);\n    \n    \/\/ Allocating memory dynamically\n    ptr=(int *)malloc(n*sizeof(int));\n    \n    \/\/ Inputing elements\n    printf(\"Enter Elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    scanf(\"%d\",(ptr+i));\n }\n    \n    \/\/ Displaying elements\n    printf(\"Entered elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    printf(\"%d \",*(ptr+i));\n }\n \n \/\/ Deallocating memory\n free(ptr);\n \n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html#p3\" name=\"p3\"\u003E3. Program to dynamically allocate memory using malloc for \"n\" integer elements, input elements and then display it. Then reallocate memory for the same pointer variable, input elements, display it and then free the memory\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdlib.h\u0026gt;\n\nint main()\n{\n    int *ptr,n,i;\n    printf(\"Enter number of elements : \");\n    scanf(\"%d\",\u0026amp;n);\n    \n    \/\/ Allocating memory dynamically\n    ptr=(int *)malloc(n*sizeof(int));\n    \n    \/\/ Inputing elements\n    printf(\"Enter Elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    scanf(\"%d\",(ptr+i));\n }\n    \n    \/\/ Displaying elements\n    printf(\"Entered elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    printf(\"%d \",*(ptr+i));\n }\n \n printf(\"\\nEnter number of elements : \");\n    scanf(\"%d\",\u0026amp;n);\n    \n    \/\/ Reallocating memory \n ptr=realloc(ptr,n);\n \n \/\/ Inputing elements\n    printf(\"Enter Elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    scanf(\"%d\",(ptr+i));\n }\n    \n    \/\/ Displaying elements\n    printf(\"Entered elements : \");\n    for(i=0;i\u0026lt;n;i++)\n    {\n    printf(\"%d \",*(ptr+i));\n }\n \n \/\/ Deallocating memory\n free(ptr);\n    \n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html#p4\" name=\"p4\"\u003E4. Program to find the length of the string\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdlib.h\u0026gt;\nvoid main()\n{\n char *ptr;\n \n \/\/ Declaring variable i=to iterate loop, l=lenght of string\n int i, l=0;\n \n    \/\/ Allocating memory\n ptr=(char *)malloc(12*sizeof(char));\n \n \/\/ Inputing string\n printf(\"Enter string : \");\n gets(ptr);\n \n \/\/ Displaying string\n printf(\"Entered string : \");\n puts(ptr);\n \n \/\/ Calculating length\n while(ptr[l]!='\\0')\n {\n l++;\n }\n \n \/\/ Printing length of string\n printf(\"Lenght of string : %d\",l);\n \n \/\/ Deallocating memory\n free(ptr);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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\/6914796806847001338\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6914796806847001338"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6914796806847001338"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html","title":"C PROGRAMS : DYNAMIC MEMORY ALLOCATION"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-6794134224349899676"},"published":{"$t":"2014-01-29T06:56:00.000-08:00"},"updated":{"$t":"2014-04-16T01:02:49.375-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Pointers"}],"title":{"type":"text","$t":"C PROGRAMS : POINTERS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : POINTERS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p6\" name=\"p6\"\u003E6. Program to find maximum element of an array of elements using pointer\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring array variable \"a\" of size 10, i=to iterate loop, max=maximum element\n int a[10], i, max;\n \n \/\/ Declaring pointer variable pointing to the the base address i.e ( a[0] )of array 'a'  \n int *ptr=a; \/\/ It is equivalent to : int *ptr; ptr=\u0026amp;a;\n \n \/\/ Inputing array elements\n printf(\"Enter 10 elements in an array : \");\n for(i=0;i\u0026lt;10;i++)\n {\n  scanf(\"%d\",\u0026amp;a[i]);\n }\n \n \/\/ Assigning first element to max, ptr points to second element after post increment\n max=*ptr++;\n \n \/\/ Determining maximum value\n for(i=0;i\u0026lt;10;i++)\n {\n  if(*ptr \u0026gt; max)\n  {\n   max=*ptr;\n   ptr++;\n  }\n }\n \n \/\/ Printing maximum value\n printf(\"\\nMaximum value : %d\",max);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p7\" name=\"p7\"\u003E7. Program to print sum of all the elements in 2D array using pointer\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring 2D array and initializing it\n int a[3][4]={{3,4,5,6},{5,6,7,8},{8,9,10,11}};\n \n \/\/ Declaring varaible sum\n int sum=0;\n \n \/\/ Declaring pointer variable\n int *ptr, *ptre;\n \n ptr=\u0026amp;a[0][0]; \/\/ points to address of first element\n ptre=ptr+12; \n \n \/\/ Calculating sum\n while(ptr\u0026lt;ptre)\n {\n  sum+=*ptr++;\n }\n \n \/\/ Displaying calculated sum\n printf(\"Sum of all elements : %d\",sum);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p8\" name=\"p8\"\u003E8. Program to sort an array of elements using pointers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n\n \/\/ Declaring array and initializing it\n int a[]={5,6,3,4,5};\n\n \/\/ Declaring pointer variable *p, *q and temp=tempeorary that helps in swapping numbers\n int *p,*q,temp;\n\n \/\/ Declaring variable i, j to iterate loop\n int i,j;\n\n \/\/Displaying array elements\n printf(\"Array elements : \");\n for(i=0;i\u0026lt;5;i++)\n {\n  printf(\"%d \",a[i]);\n }\n printf(\"\\n\");\n \n \/\/ Pointing to the address of first element\n p=\u0026amp;a[0];\n \n \/\/ Performing sorting\n for(i=0;i\u0026lt;5;i++)\n {\n  for(j=i+1;j\u0026lt;5;j++)\n  {\n   \/\/ Swapping elements\n   if(*(p+i) \u0026gt; *(p+j))\n   {\n    temp=*(p+i);\n    *(p+i)=*(p+j);\n    *(p+j)=temp;\n   }\n  }\n }\n\n \/\/ Displaying sorted elements\n printf(\"Sorted elements : \");\n for(i=0;i\u0026lt;5;i++)\n {\n  printf(\"%d \",a[i]);\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p9\" name=\"p9\"\u003E9. Program to sort string using pointers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str\n char str[50], *p;\n \n \/\/ Declaring variable i, j to iterate loop\n int i, j;\n \n \/\/ Declaring variable l=length, temp=tempeorary that helps in swapping\n int l=0, temp;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n p=\u0026amp;str[0];\n \n \/\/ finding length\n while(str[l]!='\\0')\n l++;\n \n \/\/ Performing sorting\n for(i=0;i\u0026lt;l;i++)\n {\n  for(j=i+1;j\u0026lt;l;j++)\n  {\n   \/\/ Swapping characters\n   if(*(p+i)\u0026gt;*(p+j))\n   {\n    temp=*(p+i);\n    *(p+i)=*(p+j);\n    *(p+j)=temp;\n   }\n  }\n }\n \n \/\/ Displaying sorted string\n printf(\"Sorted string : \\n\");\n p=\u0026amp;str[0];\n \n for(i=0;i\u0026lt;l;i++)\n {\n  printf(\"%c\\n\",*(p+i));\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p10\" name=\"p10\"\u003E10. Program to search given element in an array using pointers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n\n \/\/ Declaring array and initializing it, *p=points to the address of first element\n int a[]={5,6,3,4,5}, *p;\n p=\u0026amp;a[0];\n \n \/\/ Declaring variable i = to iterate loop\n int i;\n \n \/* Declaring variable es = element to be searched, flag = to indicate \n if element is present or not *\/\n int es, flag=0;\n \n \/\/ Displaying array element\n printf(\"Array elements : \");\n for(i=0;i\u0026lt;5;i++)\n {\n  printf(\"%d \",*(p+i));\n }\n \n \/\/ Inputing element to be searched\n printf(\"\\nEnter element to be searched : \");\n scanf(\"%d\",\u0026amp;es);\n \n \/\/ Searching element\n for(i=0;i\u0026lt;5;i++)\n {\n  if(*(p+i)==es)\n  {\n   flag=1;\n   break;\n  }\n }\n \n \/\/ Displaying whether element found or not\n if(flag==1)\n printf(\"Element found \");\n \n else\n printf(\"Element not found \");\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p11\" name=\"p11\"\u003E11. Program to demonstrate the use of pointer to pointer\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n int x,*p,**q;\n             \n    printf(\"\\nEnter a number : \");\n    scanf(\"%d\",\u0026amp;x);\n    \n    p=\u0026amp;x;\n    q=\u0026amp;p;\n    \n    printf(\"\\nValue of x=%d\",x);\n    printf(\"\\nValue of x through pointer=%d\",*p);\n    printf(\"\\nVal. of x through pointer to  pointer=%d\",**q);\n    printf(\"\\nValue of p=%u\",p);\n    printf(\"\\nValue of q=%u\",q);\n    printf(\"\\nAddres of p=%u\",q);\n     \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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\/6794134224349899676\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6794134224349899676"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6794134224349899676"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html","title":"C PROGRAMS : POINTERS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-1916316238468921225"},"published":{"$t":"2014-01-29T06:48:00.000-08:00"},"updated":{"$t":"2014-04-16T01:03:09.050-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Pointers"}],"title":{"type":"text","$t":"C PROGRAMS : POINTERS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : POINTERS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p1\" name=\"p1\"\u003E1. Program to accept two numbers and print its address along with the numbers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main( )\n{\n \/\/ Declaring variable a, b = two numbers\n int a, b;\n \n \/\/ Inputing two numbers\n printf(\"Enter first number : \");\n scanf(\"%d\",\u0026amp;a);\n \n printf(\"Enter first number : \");\n scanf(\"%d\",\u0026amp;b);\n \n \/\/ Printing address along with number\n printf(\"First number : %d, Address : %d\\n\",a, \u0026amp;a);\n printf(\"First number : %d, Address : %d\\n\",*(\u0026amp;a), \u0026amp;a);\n \n printf(\"Second number : %d, Address : %d\\n\",b, \u0026amp;b);\n printf(\"Second number : %d, Address : %d\",*(\u0026amp;b), \u0026amp;b);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p2\" name=\"p2\"\u003E2. Program to accept two numbers and print the sum of given two numbers by using pointers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main( )\n{\n \/\/ Declaring variable a, b = two numbers\n int a, b;\n \n \/\/ Declaring variale s=sum\n int s=0;\n \n \/\/ Inputing two numbers\n printf(\"Enter first number : \");\n scanf(\"%d\",\u0026amp;a);\n \n \/\/ Inputing second number\n printf(\"Enter first number : \");\n scanf(\"%d\",\u0026amp;b);\n \n \/\/ Determining sum\n s=*(\u0026amp;a)+*(\u0026amp;b);\n \n \/\/ Printing sum\n printf(\"Sum = %d\",s);\n \n getch( ); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p3\" name=\"p3\"\u003E3. Program to interchange two values using pointers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable a, b for two values, swap to interchange value\n int a, b, swap;\n \n \/\/ Declaring pointer that holds address of two values\n int *c, *d;\n \n \/\/ Storing address\n c=\u0026amp;a;\n d=\u0026amp;b;\n \n \/\/ Inputing values\n printf(\"Enter first value a : \");\n scanf(\"%d\",\u0026amp;a);\n \n printf(\"Enter second value b : \");\n scanf(\"%d\",\u0026amp;b);\n \n \/\/ Printing original value\n printf(\"Original value : a = %d, b = %d\\n\",a, b);\n \n \/\/ Interchanging value\n swap=*c;\n *c=*d;\n *d=swap;\n \n \/\/ Printing interchanged value\n printf(\"Interchanged value : a = %d, b = %d \",a, b);\n  \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p4\" name=\"p4\"\u003E4. Implement a function interchange() to interchange two values using pointers \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable a, b for two values\n int a,b;\n\n \/\/ Inputing values\n printf(\"Enter first value a : \");\n scanf(\"%d\",\u0026amp;a);\n \n printf(\"Enter second value b : \");\n scanf(\"%d\",\u0026amp;b);\n \n \/\/ Printing original value\n printf(\"Original value : a = %d, b = %d\\n\",a, b);\n \n \/\/ Calling function interchange\n interchange(\u0026amp;a, \u0026amp;b);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\n\nvoid interchange(int *x, int *y)\n\n{\n int swap;\n \n \/\/ Interchanging value\n swap=*x;\n *x=*y;\n *y=swap;\n \n \/\/ Printing interchanged value\n printf(\"Interchanged value : a = %d, b = %d \",*x, *y);\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p5\" name=\"p5\"\u003E5. Program to sum all the elements of an array using pointer\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring array variable \"a\" of size 10 and initializing it\n int a[10]={21, -2, 4, 6, 9, 12, 43, 22, 4, 8}, sum=0;\n \n \/\/ Declaring pointer type variable pointing to the the base address i.e ( a[0] ) of array 'a'  \n int *ptr=a; \/\/ It is equivalent to : int *ptr; ptr=\u0026amp;a;\n \n \/\/ Declaring variable ptre = stores address of 11th element\n int *ptre;\n ptre = ptr+10;\n \n \/\/ Calculating sum\n while(ptr\u0026lt;ptre)\n {\n  sum+=*ptr++; \/\/ sum=sum + *ptr++\n }\n \n \/\/ Displaying calculated sum\n printf(\"Sum of all elements : %d \",sum);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\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\/1916316238468921225\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/1916316238468921225"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/1916316238468921225"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html","title":"C PROGRAMS : POINTERS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-2178441596240428818"},"published":{"$t":"2014-01-29T06:37:00.000-08:00"},"updated":{"$t":"2014-04-16T01:03:28.008-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#21\" name=\"21\"\u003E21. Program to accept a string and print each word of the string separately also print total number of words\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string, word=to store the word\n char str[50], word[50];\n \n \/* Declaring variable cw=count words, i=to iterate loop, \n j=works as index position of word *\/\n int cw=0, i, j=0;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/* We are concatinating a space here assuming user does not \n give space at the last *\/\n strcat(str,\" \");\n\n \/\/ Printing string\n printf(\"Entered string : %s\",str);\n \n \/\/Determing total number of words and displaying it\n for(i=0;str[i]!='\\0';i++)\n {\n  if(str[i]!=' ')\n  {\n   word[j++]=str[i];\n  }\n  else\n  {\n   word[j]='\\0';\n   printf(\"\\nWord : %s\",word);\n   cw++;\n   j=0;\n  }\n }\n \n \/\/ Printing total words\n printf(\"\\nTotal number of words : %d\",cw);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#22\" name=\"22\"\u003E22. Program to accept a string and display vowels frequency( total number of vowels)\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/* Declaring variable cv=count vowel, i=to iterate loop \n ( i works as index position) *\/\n int cv=0, i;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Checking if vowels and counting them\n for(i=0;str[i]!='\\0';i++)\n {\n  if(str[i]=='a' || str[i]=='A' || str[i]=='e' || str[i]=='E' || \n  str[i]=='i' || str[i]=='I' || str[i]=='o' || str[i]=='O' || \n  str[i]=='u' ||str[i]=='U')\n  {\n   cv++;\n  }\n }\n \n \/\/ Printing total number of vowels\n printf(\"Entered String : %s\",str);\n printf(\"\\nTotal number of vowels : %d\",cv);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#23\" name=\"23\"\u003E23. Program to accept a string and display frequency of each vowel along with vowel\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/\/ Declaring variable ca=count vowel a\n int ca=0, ce=0, ci=0, co=0, cu=0;\n \n \/\/ Declaring variable i=to iterate loop ( i works as index position)\n int i;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Determining frequency of each vowel\n for(i=0;str[i]!='\\0';i++)\n {\n  if(str[i]=='a' || str[i]=='A')\n  ca++;\n  \n  if(str[i]=='e' || str[i]=='E')\n  ce++;\n  \n  if(str[i]=='i' || str[i]=='I')\n  ci++;\n  \n  if(str[i]=='o' || str[i]=='O')\n  co++;\n  \n  if(str[i]=='u' || str[i]=='U')\n  cu++;\n  \n }\n \n \/\/ Printing string\n printf(\"Entered String : %s\",str);\n \n \/\/ Printing frequency of string\n printf(\"\\nFrequency of 'a' or 'A' : %d\",ca);\n printf(\"\\nFrequency of 'e' or 'E' : %d\",ce);\n printf(\"\\nFrequency of 'i' or 'I : %d\",ci);\n printf(\"\\nFrequency of 'o' or 'O' : %d\",co);\n printf(\"\\nFrequency of 'u' or 'U' : %d\",cu);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#24\" name=\"24\"\u003E24. Program to enter a word and check whether it is palindrome or not using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ palindrom - When word = reverse of word then it is called palindrome\n\/\/ Example : madam - palindrome, Madam - not palindrome, MadaM - palindrome\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \n char word[50], word1[50];\n \n \/\/ Inputing string\n printf(\"Enter any word : \");\n scanf(\"%s\",\u0026amp;word);\n\n \/\/ Copying word to word1\n strcpy(word1,word);\n \n \/\/ checking if palindrome or not\n if(strcmp(word,strrev(word1))==0)\n {\n  printf(\"Entered word is a palindrome \");\n }\n \n else\n printf(\"Entered word is not palindrome \");\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#25\" name=\"25\"\u003E25. Program to enter a word and check whether it is palindrome or not without using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string \n char word[50], revword[50];\n \n \/* Declaring variable i=to iterate loop, l=length, \n c=count the number of matched character *\/\n int i, j, l=0, c;\n \n \/\/ Inputing string\n printf(\"Enter any word : \");\n scanf(\"%s\",\u0026amp;word);\n\n \/\/ finding length\n while(word[l]!='\\0')\n l++;\n \n \/\/ Reversing string\n j=0;\n for(i=l-1;i\u0026gt;=0;i--)\n {\n  revword[j]=word[i];\n  j++;\n }\n revword[j]='\\0';\n \n \/\/checking if palindrome or not\n c=0;\n for(i=0;word[i]!='\\0';i++)\n {\n  if(revword[i]==word[i])\n  c++;\n }\n \n if(c==l)\n {\n  printf(\"Word is a palindrome \");\n }\n \n else\n printf(\"Word is not palindrome \");\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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\/2178441596240428818\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/2178441596240428818"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/2178441596240428818"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-8155720132451611306"},"published":{"$t":"2014-01-29T06:24:00.000-08:00"},"updated":{"$t":"2014-04-16T01:03:41.196-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#16\" name=\"p16\"\u003E16. Program to convert all characters in a string to lower case using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Printing string\n printf(\"Entered String : %s\\n\",str);\n \n \/\/ Converting to lower case\n strlwr(str);\n \n \/\/ Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\u003C\/pre\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#17\" name=\"p17\"\u003E17. Program to convert all characters in a string to lower case without using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string, ch=character\n char str[50], ch;\n \n \/\/ Declaring variable i=to iterate loop\n int i;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Printing string\n printf(\"Entered String : %s\\n\",str);\n \n  \n \/\/ Converting to lower case\n for(i=0;str[i]!='\\0';i++)\n    {\n        ch=str[i];\n        \n        if(ch\u0026gt;=65 \u0026amp;\u0026amp; ch\u0026lt;97)\n        {\n            ch+=32; \/\/ ch1=ch1+32\n            str[i]=ch;\n        }\n    }\n    \n    \/\/ Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#18\" name=\"p18\"\u003E18. Program to convert all characters in a string to upper case using string function\u003Cbr \/\u003E\n\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Printing string\n printf(\"Entered String : %s\\n\",str);\n \n \/\/ Converting to lower case\n strupr(str);\n \n \/\/ Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#19\" name=\"p19\"\u003E19. Program to convert all characters in a string to upper case without using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string, ch=character\n char str[50], ch;\n \n \/\/ Declaring variable i=to iterate loop\n int i;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Printing string\n printf(\"Entered String : %s\\n\",str);\n \n  \n \/\/ Converting to lower case\n for(i=0;str[i]!='\\0';i++)\n    {\n        ch=str[i];\n        \n        if(ch\u0026gt;=97 \u0026amp;\u0026amp; ch\u0026lt;=122)\n        {\n            ch-=32; \/\/ ch1=ch1-32\n            str[i]=ch;\n        }\n    }\n    \n    \/\/ Printing converted string\n printf(\"Converted string : %s\\n\",str);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E \u003Cspan style=\"color: blue;\"\u003Ereturn 0;\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#20\" name=\"p20\"\u003E20. Program to enter 5 string and print them with their length\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/* Declaring variable str[5][50]- This means that 5 string is to be input \n with max size of each string = 50 *\/\n char str[5][50];\n \n \/\/ Declaring variable i=to iterate loop\n int i;\n \n \/\/ Inputing string\n for(i=0;i\u0026lt;5;i++)\n {\n  printf(\"Enter %d string : \", i+1);\n  gets(str[i]);\n }\n \n \/\/ Printing string with its length\n for(i=0;i\u0026lt;5;i++)\n {\n  printf(\"\\nString %d : %s \",i+1, str[i]);\n  printf(\"\\nString length : %d\",strlen(str[i]));\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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\/8155720132451611306\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/8155720132451611306"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/8155720132451611306"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-594002653997889306"},"published":{"$t":"2014-01-29T06:14:00.000-08:00"},"updated":{"$t":"2014-04-16T01:04:11.102-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#10\" name=\"p10\"\u003E10. Program for Compare two String using String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string1 , str2=string2\n char str1[50], str2[50];\n \n \/\/ Inputing string\n printf(\"Enter first string : \");\n gets(str1);\n \n printf(\"Enter second string : \");\n gets(str2);\n \n \/\/ Printing string\n printf(\"First String : %s\\n\",str1);\n printf(\"Second string : %s\\n\",str2);\n \n \/\/ Comparing string\n if(strcmp(str1,str2)==0)\n {\n  printf(\"Same string or string are equal\");\n }\n \n else if(strcmp(str1,str2)\u0026lt;0)\n {\n  printf(\"First string is smaller \");\n }\n \n else if(strcmp(str1,str2)\u0026gt;0)\n {\n  printf(\"Second string is smaller \");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#11\" name=\"p11\"\u003E11. Program for Compare two String without using String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n  \/\/ Declaring variable str1=string1, str2=string2\n  char str1[50],str2[50];\n  \n  \/\/ Declaring variable ch1=character of string1, ch2=character of string2\n  char ch1,ch2;\n  \n  \/\/ Declaring variable i=to iterate loop, flag = to indicate comparision\n     int i,flag=0;\n               \n        \/\/ Inputing string       \n        printf(\"\\nEnter First String : \" );\n        gets(str1);\n        \n        printf(\"\\nEnter Second String : \" );\n     gets(str2);\n     \n     \/\/ Comparing string\n  for(i=0;str1[i]!='\\0';i++)\n        {\n            ch1=str1[i];\n            ch2=str2[i];\n            if(ch1\u0026gt;=97 \u0026amp;\u0026amp; ch1\u0026lt;=122)\n            {\n                ch1-=32; \/\/ ch1=ch1-32\n            }\n            if(ch2\u0026gt;=97 \u0026amp;\u0026amp; ch2\u0026lt;=122)\n            {\n                ch2-=32; \/\/ ch2=ch2-32\n            }\n            if(ch1!=ch2)\n            {\n                flag=1;\n                break;\n            }\n        }\n               if(flag==0)\n                   {\n                        printf(\"\\nString  '%s' and  '%s' are equal \",str1,str2);\n                   }\n               else\n                   {\n                        printf(\"\\nString  '%s' and  '%s' are Not equal \",str1,str2);\n                   }\n\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#12\" name=\"p12\"\u003E12. Program for String Reverse with String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n\n \/\/ Printing string and reversed string\n printf(\"String : %s\\n\",str);\n printf(\"Reversed string : %s\",strrev(str));\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#13\" name=\"p10\"\u003E13. Program for String Reverse without String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string, revstr[50]=reverse string\n char str[50], revstr[50];\n \n \/\/ Declaring variable i=to iterate loop, l=length\n int i, j,l=0;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n\n \/\/ finding length\n while(str[l]!='\\0')\n l++;\n \n \/\/ Reversing string\n j=0;\n for(i=l-1;i\u0026gt;=0;i--)\n {\n  revstr[j]=str[i];\n  j++;\n }\n revstr[j]='\\0';\n \n \/\/ Printing string and reversed string\n printf(\"String : %s\\n\",str);\n printf(\"Reversed string : %s\",revstr);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#14\" name=\"p14\"\u003E14. Program for String Concatenation with String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string1 , str2=string2\n char str1[50], str2[50];\n \n \/\/ Inputing string\n printf(\"Enter first string : \");\n gets(str1);\n \n printf(\"Enter second string : \");\n gets(str2);\n \n \/\/ Printing string\n printf(\"First String : %s\\n\",str1);\n printf(\"Second string : %s\\n\",str2);\n \n \/\/ Concatinating string\n strcat(str1,str2); \/\/ str2 is added to str1\n \n \/\/ Printing conactinated string\n printf(\"Concatinated string : %s\\n\",str1);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#15\" name=\"p15\"\u003E15. Program for String Concatenation without String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string1 , str2=string2\n char str1[100], str2[50];\n \n \/\/ Declaring variable l=length of string1\n int l1=0;\n \n \/\/ Declaring variable i=to iterate loop\n int i;\n \n \/\/ Inputing string\n printf(\"Enter first string : \");\n gets(str1);\n \n printf(\"Enter second string : \");\n gets(str2);\n \n \/\/ Printing string\n printf(\"First String : %s\\n\",str1);\n printf(\"Second string : %s\\n\",str2);\n \n \/\/ Finding length of string1 and string2\n while(str1[l1]!='\\0')\n l1++;\n \n \/\/ Concatinating string\n for(i=0;i\u0026lt;str2[i]!='\\0';i++)\n {\n  str1[l1++]=str2[i];\n }\n str1[l1]='\\0';\n\n \/\/ Printing Concatinated stirng\n  printf(\"Concatinated string : %s\\n\",str1);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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\/594002653997889306\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/594002653997889306"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/594002653997889306"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-555835272151975336"},"published":{"$t":"2014-01-29T06:05:00.000-08:00"},"updated":{"$t":"2014-04-16T01:04:15.422-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p6\" name=\"p6\"\u003E6. Program to find length of a string using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/\/ Declaring variable l=length\n int l=0;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Determining string length\n l=strlen(str);\n \n \/\/ Printing string length\n printf(\"String : %s\\nString length : %d\",str,l);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p7\" name=\"p7\"\u003E7. Program to find length of a string without using string function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string \n char str[50];\n \n \/\/ Declaring variable l=length\n int l=0;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Determining string length\n while(str[l]!='\\0')\n {\n  l++;\n }\n \n \/\/ Printing string length\n printf(\"String : %s\\nString length : %d\",str,l);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p8\" name=\"p8\"\u003E8. Program for Copy a String to another using String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;string.h\u0026gt;\n\nint main()\n{\n \/\/ Declaring variable str=string , cs=copied string\n char str[50], cs[50];\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n \/\/ Copy string\n strcpy(cs,str);\n \n \/\/ Printing string\n printf(\"String : %s\\n\",str);\n printf(\"Copied string : %s\",cs);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p9\" name=\"p9\"\u003E9. Program for Copy a String to another without using String Function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=string , cs=copied string\n char str[50], cs[50];\n \n \/\/ Declaring variable l=length\n int l=0;\n \n \/\/ Inputing string\n printf(\"Enter any string : \");\n gets(str);\n \n while(str[l]!='\\0')\n {\n  cs[l]=str[l];\n  l++;\n }\n cs[l]='\\0';\n \n \/\/ Printing string\n printf(\"String : %s\\n\",str);\n printf(\"Copied string : %s\",cs);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Cbr \/\u003E\n\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/555835272151975336\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/555835272151975336"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/555835272151975336"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-6997950191772861278"},"published":{"$t":"2014-01-29T05:57:00.000-08:00"},"updated":{"$t":"2015-03-01T05:35:57.093-08:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"string"}],"title":{"type":"text","$t":"C PROGRAMS : STRINGS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ctitle\u003EC PROGRAMS : STRINGS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p1\" name=\"p1\"\u003E1. Program to accept a string and print it\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable str=to store string inputted by user\n char str[80];\n \n \/\/ Inputing string\n printf(\"Enter any sentence : \");\n gets(str);\n \n \/\/ printing string\n printf(\"\\nEntered String : \");\n puts(str);\n \n \/\/ Another way of printing string\n printf(\"\\nEnterd string : %s\",str);\n  \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p2\" name=\"p2\"\u003E2. Program to accept a character in the uppercase and print in lower case\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/Declaring variable ch to hold character value and cl=change to lower case \n char ch,cl;\n\n \/\/ Inputting character\n printf(\"Enter a character in uppercase : \");\n ch=getchar();\n \n \/\/ Converting it to lower case\n cl=ch+32;\n \n \/\/ Printing lower case character\n printf(\"The given character in lowercase is : %c \\n\",cl);\n \n \/\/ Another way of priting\n printf(\"The given character in lowercase is : \");\n putchar(cl);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p3\" name=\"p3\"\u003E3. Program to accept a character in Lower case and print it in upper case\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main( )\n{\n \/\/ Declaring variable ch=character, cu=change character to upper case\n char ch,cu; \n \n \/\/ Entering character\n printf(\"Enter a charcater in lower case: \");\n scanf(\"%c\",\u0026amp;ch);\n \n \/\/ Converting it to upper case\n cu=ch-32;\n \n \/\/ Printing upper case character\n printf(\"The given character in upper case is : %c \\n\",cu);\n \n  getch( ); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n  return 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p4\" name=\"p4\"\u003E4. Program to accept a character in any case and print in another case\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable ch to hold character value and cch=change character\n char ch,cch;\n\n \/\/ Inputting character\n printf(\"Enter a character in anycase : \");\n scanf(\"%c\",\u0026amp;ch);\n\n \/\/ Changing case\n if(ch\u0026gt;=65 \u0026amp;\u0026amp; ch\u0026lt;=90)\n cch=ch+32;\n \n else if(ch\u0026gt;=97 \u0026amp;\u0026amp; ch\u0026lt;=122)\n cch=ch-32;\n \n \/\/ Printing Changed case\n printf(\"Changed character : %c \",cch);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p5\" name=\"p5\"\u003E5. Program to accept a string and print it by using while loop\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable ch to store input character\n char ch; \n\n \/\/ Inputing and displaying string\n printf(\"Enter a string : \");\n while(( ch=getchar( ))!='\\n')\n putchar(ch); \n\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/6997950191772861278\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6997950191772861278"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6997950191772861278"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html","title":"C PROGRAMS : STRINGS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"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":"Array"},{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"}],"title":{"type":"text","$t":"C PROGRAMS : ARRAYS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : ARRAYS \u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays3.html#16\" name=\"16\"\u003E16. Programs to multiply two Matrices\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main( )\n{\n \/\/ Declaring variable a, b, c with max size=10 X 10\n int a[10][10],b[10][10],c[10][10];\n \n \/\/ Declaring variable m, n, p, q = size of matrix entered by user\n int m, n, p, q;\n \n \/\/ Declaring variable i, j, k = 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==p)\n {\n \/\/ Inputing first matrx elemets\n printf(\"Enter first matrices elements : \");\n \n for(i=0;i\u0026lt;m;i++)\n {\n  for(j=0;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=0;i\u0026lt;m;i++)\n {\n  for(j=0;j\u0026lt;n;j++)\n  {\n   scanf(\"%d\",\u0026amp;b[i][j]);\n  }\n }\n \n \/\/ Performing multiplication\n for(i=0;i\u0026lt;m;i++)\n {\n  for(j=0;j\u0026lt;n;j++)\n  {\n   c[i][j]=0;\n   for(k=0;k\u0026lt;n;k++)\n   {\n   c[i][j]=c[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=0;i\u0026lt;m;i++)\n {\n  for(j=0;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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays3.html#17\" name=\"17\"\u003E17. Program to print a diagonal matrix with diagonal value enter by user\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variale a with size = 4 X 4\n int a[4][4],i,j;\n \n \/\/ Declaring varibale d = 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=0;i\u0026lt;4;i++)\n {\n  for(j=0;j\u0026lt;4;j++)\n  {\n   if(i==j)\n   a[i][j]=d;\n   else\n   a[i][j]=0;\n  }\n }\n \n \/\/ Printing diagonal matrix\n for(i=0;i\u0026lt;4;i++)\n {\n \n  for(j=0;j\u0026lt;4;j++)\n  printf(\"%2d\",a[i][j]);\n  printf(\"\\n\");\n }\n  \n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays3.html#18\" name=\"18\"\u003E18. Program to print a anti diagonal matrix with diagonal value enter by user\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variale a with size = 4 X 4\n int a[4][4],i,j;\n \n \/\/ Declaring varibale d = 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=0;i\u0026lt;4;i++)\n {\n  for(j=0;j\u0026lt;4;j++)\n  {\n   if(i+j==3)\n   a[i][j]=d;\n   else\n   a[i][j]=0;\n  }\n }\n \n \/\/ Printing anti diagonal matrix\n for(i=0;i\u0026lt;4;i++)\n {\n \n  for(j=0;j\u0026lt;4;j++)\n  printf(\"%2d\",a[i][j]);\n  printf(\"\\n\");\n }\n  \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays3.html#19\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"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=to store sum of diagonal value, sa=store sum of anti diagonal value\n int sd=0, sa=0; \n \n \/\/ Inputing matrix\n printf(\"Enter matrix element of size 4 X 4 : \");\n for(i=0;i\u0026lt;4;i++)\n {\n  for(j=0;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=0;i\u0026lt;4;i++)\n {\n  for(j=0;j\u0026lt;4;j++)\n  {\n   if(i==j)\n   sd=sd+a[i][j];\n   \n   if(i+j==3)\n   sa=sa+a[i][j];\n  }\n }\n\n \/\/ Printing element of matrix \n printf(\"\\nEntered elements in matrix : \\n\");\n for(i=0;i\u0026lt;4;i++)\n {\n  for(j=0;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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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":"Array"},{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"}],"title":{"type":"text","$t":"C PROGRAMS : ARRAYS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : ARRAYS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p11\" name=\"p11\"\u003E11. Program to generate histogram of entered number\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"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=0;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=0;i\u0026lt;10;i++)\n {\n  printf(\"%4d %12d           \",i, a[i]);\n  for(j=0;j\u0026lt;a[i]; j++)\n  {\n   printf(\"*\");\n  }\n  printf(\"\\n\");\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p12\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable info with row size = 4 and column size = 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=0;i\u0026lt;4;i++)\n {\n  for(j=0;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=0;i\u0026lt;4;i++)\n {\n for(j=0;j\u0026lt;3;j++)\n {\n  printf(\"%d \",info[i][j]);\n }\n printf(\"\\n\");\n }\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p13\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable info with row size = 4 and column size = 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=0;i\u0026lt;4;i++)\n {\n  for(j=0;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=0;j\u0026lt;3;j++)\n {\n  printf(\"%d \",info[1][j]);\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p14\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\n\/\/ funciton prototype\nint sum(int[][4], int, int);\n\nint main()\n{\n \/\/ Declaring variable a with row size=2 and column size=4\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 = to hold the returned result \n int result=0;\n \n \/\/ Inputting elements\n for(i=0;i\u0026lt;2;i++)\n {\n  for(j=0;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=sum(a, 2, 4);\n \n \/\/ Printing returned result\n printf(\"Sum of elements \u0026gt; 5 in an array = %d \",result);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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=sum to hold the sum\n int s=0;\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=0;i\u0026lt;m;i++)\n {\n  for(j=0;j\u0026lt;n;j++)\n  {\n   \/\/ Checking whether element is greater than 5\n   if(p[i][j]\u0026gt;5)\n   {\n    s=s+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=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p15\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring rn=roll 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=sum and avg=average\n int s[5]={0}, avg[5]={0};\n\n \/\/ Inputting name, roll no and marks\n for(i=0;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=0;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=0;i\u0026lt;5;i++)\n {\n  for(j=0;j\u0026lt;3;j++)\n  {\n   s[i]=s[i]+marks[i][j];\n  }\n  \n  avg[i]=s[i]\/3;\n }\n \n \/\/ Printing details\n printf(\"\\nDetails of student : \\n\");\n for(i=0;i\u0026lt;5;i++)\n {\n  printf(\"\\nStudent Roll Number : %d\",rn[i]);\n  printf(\"\\nStudent Total marks = %d, Average marks = %d\\n\",s[i],avg[i]);\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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":"Array"},{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"}],"title":{"type":"text","$t":"C PROGRAMS : ARRAYS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAM : Arrays\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p6\" name=\"p6\"\u003E6. Program to find Minimum element in an array\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"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=minimum\n int min;\n \n \/\/ Inputting Element of an array\n printf(\"Enter five element in an array : \\n\");\n for(i=0;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=a[0];\n \n \/\/ Determining minimum element\n for(i=0;i\u0026lt;5;i++)\n {\n if(min\u0026gt;a[i+1])\n min=a[i+1];\n }\n \n \/\/ Displaying minimum element\n printf(\"Minimum Element = %d\",min);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\n\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p7\" name=\"p7\"\u003E7. Program to find highest minimum(-) temperature and lowest maximum(+) temperature\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n int i,j;\n int counternegative=0, counterpositive=0;\n int temp[12];\n int max=0;\n int min=0;\n printf(\"Enter temperature of 12 months : \" );\n \n for(i=0;i\u0026lt;12;i++)\n {\n  scanf(\"%d\",\u0026amp;temp[i]); \n }\n \n for(i=0;i\u0026lt;12;i++)\n {\n  if(temp[i]\u0026gt;0 \u0026amp;\u0026amp; counterpositive==0)\n  {\n  min=temp[i];\n  counterpositive=1;\n  }\n  \n  else if(temp[i]\u0026lt;0 \u0026amp;\u0026amp; counternegative==0)\n  {\n  max=temp[i];\n  counternegative=1;\n  }\n }\n \n for(i=0;i\u0026lt;12;i++)\n {\n    if(temp[i]\u0026lt;0)\n    {\n     if(max\u0026lt;temp[i])\n     {\n     max=temp[i];\n     }\n    }\n    \n    else if(temp[i]\u0026gt;0)\n    {\n     if(min\u0026gt;temp[i])\n     {\n      min=temp[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=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p8\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main( )\n{ \n\n\/\/ Declaring variabel i = for iteration of loop\nint i,a[10];\n\n\/\/ Inputting elements\nprintf(\"Enter 10 elements : \");\nfor(i=0;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=0;i\u0026lt;=4;i++)\nprintf(\"%d \",a[i]);\n\n\/\/ Printing last five numbers in reverse order\nprintf(\"\\nPrinting last 5 numbers in reverse order : \");\nfor(i=9;i\u0026gt;=5;i--)\nprintf(\"%d \",a[i]);\n\ngetch( ); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\n\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p9\" name=\"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=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"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=0;\n   \n   \/\/ Declaring variable \"i\" to iterate loop\n   int i;\n   \n   \/\/ Calculating sum \n      for(i=0;i\u0026lt;5;i++)\n      {\n              sum=sum+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=0;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 = %f\",avg(marks));\n\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\n\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p10\" name=\"p10\"\u003E10. Program to initialize a character array and display the it in reverse order\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable names of size 5 and initializing it\n char names[5]={'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=4;i\u0026gt;=0;i--)\n  {\n  printf(\"%c \",names[i]);\n }\n\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"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":"Array"},{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"}],"title":{"type":"text","$t":"C PROGRAMS : ARRAYS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : Array\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p1\" name=\"p1\"\u003E1. Program to accept elements in an array and display it\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n    \/\/ Declaring array variable with max size=10\n    int a[10];\n\n   \/\/ Declaring variable i = to iterate loop\n   int i;\n\n   \/\/ Inputting elements\n   printf(\"Enter 10 elements in an array : \");\n   for(i=0; 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=0; i\u0026lt;10; i++)\n   {\n        printf(\"%d \",a[i]);\n   }\n\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E   \/\/ to hold the screen defined in conio.h\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E  \u0026nbsp;\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E   getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n   return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p2\" name=\"p2\"\u003E2. Program to accept elements in an array and display sum of all the elements\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n    \/\/ Declaring array variable with size=10\n    int a[10]; \n\n   \/\/ Declaring variable s=sum to store the sum, i = to iterate loop\n   int i, s=0;\n\n   \/\/ Inputting elements\n   printf(\"Enter 10 elements in an array : \");\n   for(i=0; 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=0; i\u0026lt;10; i++)\n   {\n        printf(\"%d \",a[i]);\n   }\n\n   \/\/ Performing sum of all elements\n    for(i=0; i\u0026lt;10; i++)\n   {\n        s = s + a[i];\n   }\n\n   \/\/ Displaying result\n   printf(\"\\nSum of all elements  :  %d \",s);\n\n   getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n   return 0;\n}\n\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p3\" name=\"p3\"\u003E3. Program to insert element in between an array. ( INSERTION )\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n\/\/ Declaring variable \"i\" to iterate loop\nint i;\n\n\/\/ Declaring variable pos=postion from where we want to delete element\nint pos;\n\n\/\/ Declaring n=number which we want to insert and \"m\" to store \"n\"\nint n,m;\n\n\/\/ Declaring and initialising array\nint a[6]={2,4,6,8,10};\n\n\/\/ Printing values in array before insertion\nprintf(\"Elements before deletion\\n\");\nfor(i=0;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=n;\n\n\/\/ Performing insertion\nfor(i=5;i\u0026gt;=pos-1;i--)\n{\na[i+1]=a[i];\n}\na[pos-1]=m;\n\n\/\/ Printing elements after insertion\nprintf(\"Elements after insertion\\n\");\nfor(i=0;i\u0026lt;6;i++)\n{\nprintf(\"%d \",a[i]);\n}\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p4\" name=\"p4\"\u003E4. Program to delete element from an array. ( DELETION )\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n\/\/ Declaring variable \"i\" to iterate loop\nint i;\n\n\/\/ Declaring variable pos=postion from where we want to delete element\nint pos;\n\n\/\/ Declaring and initialising array\nint a[5]={2,4,6,8,10};\n\n\/\/ Printing values in array before deletion\nprintf(\"Elements before deletion\\n\");\nfor(i=0;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=pos-1;i\u0026lt;5;i++)\n{\na[i]=a[i+1];\n}\n\n\/\/ Printing elements after deletion\nprintf(\"Elements after deletion\\n\");\nfor(i=0;i\u0026lt;4;i++)\n{\nprintf(\"%d \",a[i]);\n}\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\n\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p5\" name=\"p5\"\u003E5. Program to perform Transpose of a Matrix\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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=0;i\u0026lt;2;i++)\n{\nfor(j=0;j\u0026lt;2;j++)\n{\nscanf(\"%d\",\u0026amp;a[i][j]);\n}\n}\n\n\/\/ Displaying Matrix\nfor(i=0;i\u0026lt;2;i++)\n{\n printf(\"\\n\");\n for(j=0;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=0;i\u0026lt;2;i++)\n{\nprintf(\"\\n\");\nfor(j=0;j\u0026lt;2;j++)\n{\nprintf(\"%d \",a[j][i]);\n}\n}\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-3633621045680754238"},"published":{"$t":"2014-01-29T05:03:00.000-08:00"},"updated":{"$t":"2015-05-24T06:19:28.970-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"recursion"}],"title":{"type":"text","$t":"C PROGRAMS : RECURSION"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ctitle\u003EC PROGRAMS : RECURSION\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p6\" name=\"p6\"\u003E6. Program to find whether a number is Palindrome or not using recursion\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\n\nPalindrome Number : If Reverse of a number = Number, the number is called Palindrome No.\n\nLOGIC : Reverse of a number is found by r=(r*10)+d\nHere r=reverser and d=digit extracted from the number.\n\n *\/\n\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\n\/\/ Declaring global variable r=reverse, d=digit\nint r=0, d=0;\n\n\/\/ Defining function with parameter n = number\nint rev(int n)\n{\n\/* Base condition : Any condition where a recursive function \nor method does not invoke itself. *\/\nif(n==0)\nreturn r;\n\n\/\/ Continue calling function rev or function invoke itself\nelse\n{\n \/\/ Extracting digit\n d=n%10;\n \n \/\/ Finding reverse\n r=(r*10+d);\n \n \/\/ function invoke itself\n rev(n\/10);\n}\n}\n\nint main()\n{\n\/\/ Declaring variable n = number\nint n;\n\n\/\/ Declaring variable \"r\" to hold the reverse number\nint r;\n\n\/\/ Inputting Number\nprintf(\"Enter the Number : \");\nscanf(\"%d\",\u0026amp;n);\n\n\/\/ Calling function \"rev\" with actual parameter \"n\" passed to it\nr=rev(n);\n\n\/\/ Checking and Displaying if a Number is palindrome or Not\nif(r==n)\nprintf(\"%d is a Palindrome Number \",n);\n\nelse\nprintf(\"%d is not a Palindrome Number \",n);\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p7\" name=\"p7\"\u003E7. Program to find whether a number is Armstrong or not using recursion\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\/*\n\n\u003Cspan style=\"color: blue;\"\u003EArmstrong Number : If sum of digits cube = Number then it is called an Armstrong Number\n\nLOGIC : Sum of digits cube of a number is found by s=s+d*d*d\nHere s=sum and d=digit extracted from the number.\n\n *\/\n\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdio.h\u0026gt;\n\n\/\/ Declaring global variable r=reverse, d=digit\nint s=0, d=0;\n\n\/\/ Defining function with parameter n = number\nint sum(int n)\n{\n\/* Base condition : Any condition where a recursive function \nor method does not invoke itself. *\/\nif(n==0)\nreturn s;\n\n\/\/ Continue calling function sum or function invoke itself\nelse\n{\n \/\/ Extracting digit\n d=n%10;\n \n \/\/ Finding reverse\n s=s+d*d*d;\n \n \/\/ function invoke itself\n sum(n\/10);\n}\n}\n\nint main()\n{\n\/\/ Declaring variable n = number\nint n;\n\n\/\/ Declaring variable \"s\" to hold the sum of digits cube of number\nint s;\n\n\/\/ Inputting Number\nprintf(\"Enter the Number : \");\nscanf(\"%d\",\u0026amp;n);\n\n\/\/ Calling function \"sum\" with actual parameter \"n\" passed to it\ns=sum(n);\n\n\/\/ Checking and Displaying if a Number is Armstron or Not\nif(s==n)\nprintf(\"%d is an Armstrong Number \",n);\n\nelse\nprintf(\"%d is not an Armstrong Number \",n);\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p8\" name=\"p8\"\u003E8. Program to print the fibonacci series upto nth terms using recursion\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/* \n\nFibonacci Series : 0 1 1 2 3 5 8 13 21 34 upto nth terms.\n\n*\/\n\n#include\u0026lt;conio.h\u0026gt;\n#include\u0026lt;stdio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\n\/\/ Defining function with parameter n = number\nint fibo(int n)\n{\n\/* Base condition : Any condition where a recursive function \nor method does not invoke itself. *\/\nif(n==1)\nreturn 0;\n\nelse if(n==2)\nreturn 1;\n\n\/\/ Continue calling function fibo\nelse if(n\u0026gt;2)\nreturn fibo(n-1)+fibo(n-2);\n}\n\nint main()\n{\n\/\/ Declaring variable n = number\nint n;\n\n\/* Declaring variable \"i\" to iterate loop and \n\"term\"=holds the current number to help print the fibonacci series *\/\nint i, term;\n\n\/\/ Inputting Number\nprintf(\"Enter the value of n\\n\");\nscanf(\"%d\",\u0026amp;n);\n\n\/\/ Calling function fibo with actual parameter \"n\" passed to it and displaying the value.\nfor(i=1;i\u0026lt;=n;i++)\n{\n term=fibo(i);\n printf(\"%d \",term);\n}\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p9\" name=\"p9\"\u003E9. Program to print first \"n\" natural numbers in reverse order\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdio.h\u0026gt;\n\n\/\/ Defining function with parameter n = number\nvoid natural(int n)\n{\n\/* Base condition : Any condition where a recursive function \nor method does not invoke itself. *\/\nif(n\u0026lt;=1)\nprintf(\"%d \",n);\n\n\/\/ Continue calling function natural\nelse\n{\n printf(\"%d \",n);\n natural(n-1);\n}\n\n\n}\nint main()\n{\n\/\/ Declaring variable n = number\nint n;\n\n\/\/ Inputting Number\nprintf(\"Enter the value of n\\n\");\nscanf(\"%d\",\u0026amp;n);\n\n\/\/ Displaying the value.\nprintf(\"First %d Natural Numbers in reverse order : \\n\",n);\n\n\/\/ Calling function natural with actual parameter \"n\" passed to it \nnatural(n);\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p10\" name=\"p10\"\u003E10. Program to print pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\n\n*\n* *\n* * * \n* * * *\n* * * * *\n\n *\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint recursion(i,j)\n{\nif(i\u0026gt;5)\nreturn 0;\nelse if(j\u0026lt;=i)\n{\n printf(\"* \");\n recursion(i,j+1);\n}\nelse\n{\nprintf(\"\\n\");\nrecursion(i+1,1); \n}\n}\nint main()\n{ \n recursion(1,1);\n\u0026nbsp;\u003C\/span\u003E\u003C\/pre\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p11\" name=\"p11\"\u003E11. Program to print pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\n\n*\n* *\n* * * \n* * * *\n* * * * * till n terms\n\n *\/\n\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint recursion(i,j,n)\n{\nif(i\u0026gt;n)\nreturn 0;\nelse if(j\u0026lt;=i)\n{\n printf(\"* \");\n recursion(i,j+1,n);\n}\nelse\n{\nprintf(\"\\n\");\nrecursion(i+1,1,n); \n}\n}\nint main()\n{ int n;\n printf(\"Enter the value till which you want to print the patter:\");\n scanf(\"%d\",\u0026amp;n);\n recursion(1,1,n);\n\u0026nbsp;\u003C\/span\u003E\u003C\/pre\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/3633621045680754238\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/3633621045680754238"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/3633621045680754238"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html","title":"C PROGRAMS : RECURSION"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-8300709507896900255"},"published":{"$t":"2014-01-29T04:47:00.000-08:00"},"updated":{"$t":"2014-04-16T01:05:06.631-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"recursion"}],"title":{"type":"text","$t":"C PROGRAMS : RECURSION"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : RECURSION\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p1\" name=\"p1\"\u003E1. Program to find the factorial of a Number using recursion\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint fact(int); \/\/ Function prototype\n\nint main()\n{\n\/\/ Declaring variable n=number\nint n;\n\n\/\/ Decalring variable f = to hold the value of factorial\nint f;\n\n\/\/ Inputting Number\nprintf(\"Enter the Number : \");\nscanf(\"%d\",\u0026amp;n);\n\n\/\/ Calling Factorial function\nf=fact(n);\n\n\/\/ Printing Factorial\nprintf(\"Factorial of %d = %d \",n,f);\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\n\nint fact(int n)\n{\n\/* Base condition : Any condition where a recursive function \nor method does not invoke itself. *\/\nif(n==1)\nreturn 1;\n\n\/\/ Continue calling function fact\nelse\nreturn n*fact(n-1);\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003Cdiv\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p2\" name=\"p2\"\u003E2. Program to print sum of n natural numbers from 1 to n ( Number ) using recursion \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdio.h\u0026gt;\n\n\/\/ Defining function with parameter n = number\nint add(int n)\n{\n\/* Base condition : Any condition where a recursive function \nor method does not invoke itself. *\/\nif(n==0)\nreturn 0;\n\n\/\/ Continue calling function add\nelse\nreturn n+add(n-1);\n}\nint main()\n{\n\/\/ Declaring variable n = number\nint n;\n\n\/\/ Inputting Number\nprintf(\"Enter the value of n\\n\");\nscanf(\"%d\",\u0026amp;n);\n\n\/\/ Calling function add with actual parameter \"n\" passed to it and displaying the value.\nprintf(\"Sum of first n numbers = %d\",add(n));\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p3\" name=\"p3\"\u003E3. Program to calculate the power using recursion. Example a^b ( Here ^ = Power sign )\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\n\/\/ Defining function with parameter a=Number and b=power \nint power(int a, int b)\n{\n \/* Base condition : Any condition where a recursive function \n or method does not invoke itself. *\/\n if(b==0)\n return 1;\n \n \/\/ Continue calling function power or function invoke itself\n else\n return a*power(a,b-1);\n}\n\nint main()\n{\n \/\/ Declaring variable a= Number and b=Power\n int a, b;\n \n \/\/ Inputting Number \n printf(\"Enter Number : \");\n scanf(\"%d\",\u0026amp;a);\n \n \/\/ Inputting Power\n printf(\"Enter Power : \");\n scanf(\"%d\",\u0026amp;b);\n \n \/\/ Calling funciton power and displaying value returned by it.\n printf(\"%d ^ %d = %d \",a, b, power(a,b));\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p4\" name=\"p4\"\u003E4. Program to find the GCD ( Greatest Common Divisior ) or HCD ( Highes Common Factor ) using recursion\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/* \n\nLOGIC : \n\nThe gcd of \"a\" and \"b\" is the same as the gcd of \"a\" and \"a%b\"\n\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\n\/\/ Defining function with parameter a = First Number and b=Second Number\nint gcd(int a, int b)\n{\n \/* Base condition : Any condition where a recursive function \n or method does not invoke itself. *\/\n if(b==0)\n return a;\n \n \/\/ Continue calling function gcd or function invoke itself\n else\n return gcd(b,a%b);\n}\n\nint main()\n{\n \/\/ Declaring variable a=First Number and b=Second Number\n int a,b;\n \n \/\/ Inputting First Number\n printf(\"Enter First Number : \");\n scanf(\"%d\",\u0026amp;a);\n \n \/\/ Inputting Second Number\n printf(\"Enter First Number : \");\n scanf(\"%d\",\u0026amp;b);\n \n \/\/ Calling funciton gcd and displaying value returned by it.\n printf(\"GCD of %d, %d = %d\",a,b,gcd(a,b));\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p5\" name=\"p5\"\u003E5. Program to Reverse a Number using recursion\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\nLOGIC : Reverse of a number is found by r=(r*10)+d\nHere r=reverser and d=digit extracted from the number.\n\n *\/\n\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;stdio.h\u0026gt;\n\n\/\/ Declaring global variable r=reverse, d=digit\nint r=0, d=0;\n\n\/\/ Defining function with parameter n = number\nint rev(int n)\n{\n\/* Base condition : Any condition where a recursive function \nor method does not invoke itself. *\/\nif(n==0)\nreturn r;\n\n\/\/ Continue calling function rev or function invoke itself\nelse\n{\n \/\/ Extracting digit\n d=n%10;\n \n \/\/ Finding reverse\n r=(r*10+d);\n \n \/\/ function invoke itself\n rev(n\/10);\n}\n}\n\nint main()\n{\n\/\/ Declaring variable n = number\nint n;\n\n\/\/ Inputting Number\nprintf(\"Enter the Number : \");\nscanf(\"%d\",\u0026amp;n);\n\n\/\/ Calling function \"rev\" with actual parameter \"n\" passed to it and displaying the value.\nprintf(\"Reverse of number = %d\",rev(n));\n\ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\u003C\/div\u003E\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/8300709507896900255\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/8300709507896900255"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/8300709507896900255"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html","title":"C PROGRAMS : RECURSION"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-8152835660017127579"},"published":{"$t":"2014-01-29T04:30:00.000-08:00"},"updated":{"$t":"2014-04-16T01:06:24.004-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"functions"}],"title":{"type":"text","$t":"C PROGRAMS : FUNCTION"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : FUNCTION\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p6\" name=\"p6\"\u003E6. Write a function that receives a positive integer as input and returns the leading digit in its decimal representation \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ For example : the leading digit of 4567 is 4\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint leading_digit(int n)\n{\n \/\/ Declaring variable d=digit to store the digits extracted from number\n int d;\n \n \/\/ Performing digit extraction\n while(n)\n {\n  d=n%10;\n  n=n\/10;\n }\n \n \/\/ Returning leading digit\n return (d);\n}\n\nint main()\n{\n \/\/ Declaring variable \"n\" to input a number\n int n;\n \n \/\/ Inputting number\n printf(\"Enter any positve integer number : \");\n scanf(\"%d\",\u0026amp;n);\n \n \/\/ Calling function and printing result\n printf(\"Leading digit of number : %d = %d \",n, leading_digit(n));\n\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\n\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p7\" name=\"p7\"\u003E7. Implement a function that receives an integer value and returns the number of prime factors of that number. If the number is itself a prime number then return 0\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\nFor example : \nfor number 21, the function should return 2 as the prime factors of 21 is 3, 7\nfor number 3, 71 the function should return 0 as 3, 71 are prime numbers\n*\/\n \n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint prime_factors(int n)\n{\n \/\/ Decaring variable \"i\", \"j\" to iterate loop, c=counter\n int i, j, c;\n \n \/\/ Declaring variable cp=count prime to count the number of prime numbers\n int cp = 0;\n \n \/\/ Determining number of prime factors\n for(i=2; i\u0026lt;=n\/2; i++)\n {\n  c=0;\n  if(n%i==0)\n  { \n  for(j=1; j\u0026lt;=i\/2; j++)\n  {\n   if(i%j==0)\n   {\n    c++;\n   }\n  }\n  \n  if(c\u0026lt;=1)\n  {\n   cp++;\n  }\n  }\n  \n }\n \n \/\/ Returning number of prime factors\n return (cp);\n \n}\n\n\nint main()\n{\n \/\/ Declaring variable \"n\" to input a number\n int n;\n \n \/\/ Inputting number\n printf(\"Enter any positve integer number : \");\n scanf(\"%d\",\u0026amp;n);\n \n \/\/ Calling funtion and printing result\n printf(\"Number of prime factors of %d = %d \",n, prime_factors(n));\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p8\" name=\"p8\"\u003E8. Program to find maximum number between three numbers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\n\/\/ Function prototype\nint maximum(int x, int y, int z);\n\nint main()\n{\n \/\/ Declaring variable n1, n2, n3 to take the input of three numbers\n int n1, n2, n3;\n \n \/\/ Inputting value\n printf(\"Enter first number : \");\n scanf(\"%d\",\u0026amp;n1);\n \n printf(\"Enter second number : \");\n scanf(\"%d\",\u0026amp;n2);\n \n printf(\"Enter third number : \");\n scanf(\"%d\",\u0026amp;n3);\n \n \/\/ Calling function maximum() and printing the returned maximum value\n printf(\"Maximum between three numbers : %d \", maximum(n1, n2, n3));\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\n\nint maximum(int x, int y, int z)\n{\n \/\/ Decalring variable max to store max value\n int max = x; \/\/ Assuming x to be maximum\n \n if(max\u0026lt;y)\n {\n  max=y;\n }\n \n if(max\u0026lt;z)\n max=z;\n \n \/\/ Returning maximum value\n return (max);\n \n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p9\" name=\"p9\"\u003E9. Program to accept a number and print the sum of given and Reverse number using function\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main( )\n{\n\n \/\/ Declaring variable n=to store the entered number by user\n int n; \n\n \/* Declaring variable r=reverse to store the reverse of a number, \n s=sum to store the sum of given and reverse number *\/\n int r, s;\n \n printf(\"Enter a number : \");\n scanf(\"%d\",\u0026amp;n);\n \n \/\/ Calling funciton rev and storing the result in \"r\"\n r=rev(n);\n \n \/\/ Displaying reverse number\n printf(\"Reverse of a number = %d\",r);\n \n \/\/ Calling function add\n s=add(n,r); \n \n \/\/ Displaying result or sum\n printf(\"\\nSum of a given and reverse number = %d\",s);\n \n getch( ); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n }\n \n int rev( int n)\n {\n  \/* Declaring variable d=digit to store the extracted digit, \n  rev=reverse to store reversed number *\/\n  int d,rev=0;\n  \n  while(n\u0026gt;0)\n  {\n   d=n%10;\n   rev=rev*10+d;\n   n=n\/10;\n  }\n  \n  \/\/ Returning reversed number\n  return rev;\n  }\n  \n  int add(int n, int r)\n  {\n   \/\/ Returning sum of given and reverse number\n   return n+r;\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\/8152835660017127579\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/8152835660017127579"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/8152835660017127579"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html","title":"C PROGRAMS : FUNCTION"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-6959814840319685669"},"published":{"$t":"2014-01-29T04:15:00.000-08:00"},"updated":{"$t":"2014-04-16T01:06:26.707-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"functions"}],"title":{"type":"text","$t":"C PROGRAMS : FUNCTION"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : FUNCTION\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p1\" name=\"p1\"\u003E1.Program to find sum of two numbers using function sum(int,int) that returns sum value \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint sum( int a, int b )\n{\nreturn a+b;\n}\n\nint main()\n{\n \n\/\/ Declaring variable x, y to take the input of two numbers\nint x, y;\n\n\/\/ Inputting value\nprintf(\"Enter the value of x:\");\nscanf(\"%d\", \u0026amp;x);\nprintf(\"Enter the value of y:\");\nscanf(\"%d\", \u0026amp;y);\n\n\/\/ Displaying value by calling sum function\n printf(\"Sum of %d and %d : %d\", x, y, sum(x, y));\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p2\" name=\"p2\"\u003E2. Program to print the area of a rectangle \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nvoid area()\n{\n \/\/ Declaring variable l=length, b = breadth\n int l,b;\n \n \/\/ Inputting length and breadth \n printf(\"Enter length of rectangle : \");\n scanf(\"%d\",\u0026amp;l);\n \n printf(\"Enter breadth of rectangle : \");\n scanf(\"%d\",\u0026amp;b);\n \n \/\/ Calculating and printing area\n printf(\"Area of rectangle %d * %d = %d \", l, b, l*b);\n \n}\n\nint main()\n{\n area();\n\u0026nbsp;\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p3\" name=\"p3\"\u003E3. Program to find the factorial of two numbers and add them and print the result \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\n\/\/ Function prototype \nint factorial(int);\n\nint main()\n{\n \/\/ Decalring variable n1, n2 to input two number\n int n1, n2;\n \n \/\/ Declaring variable f1 and f2 to store the factoial of n1, n2 respectively\n int f1, f2;\n \n \/\/ Declaring variable sum to store the sum of f1 and f2\n int sum=0;\n \n \/\/ Inputting two numbers\n printf(\"Enter first number : \");\n scanf(\"%d\", \u0026amp;n1);\n \n printf(\"Enter second number : \");\n scanf(\"%d\", \u0026amp;n2);\n \n \/\/ Calling function factorial\n f1 = factorial(n1);\n f2 = factorial(n2);\n \n \/\/ Calculating sum and displaying result\n sum = f1 + f2;\n\n printf(\"Factorial of first number %d = %d \\n\", n1, f1);\n printf(\"Factorial of second number %d = %d \\n\", n2, f2);\n printf(\"Sum of factorial of two numbers %d and %d = %d \",n1, n2, sum);\n  \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\n\nint factorial(int n)\n{\n \/\/ Declaring variable \"i\" to iterate loop\n int i;\n \n \/\/ Declaring variabl fact to store factorial\n int fact=1;\n \n \/\/ Calculating factorial\n for(i=1;i\u0026lt;=n;i++)\n {\n  fact = fact * i;\n }\n \n \/\/ Returning factorial\n return (fact);\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p4\" name=\"p4\"\u003E4. Program to implement functions that returns HCF OR GCD and LCM of two numbers \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint calculatehcf(int x, int y)\n{\n \/\/ Declaring varibale \"i' to iterate loop\n int i;\n \n \/\/ Declaring variable hcf to store calculated hcf\n int hcf=1;\n \n for(i=1; i\u0026lt;=x;i++)\n {\n  if(x%i==0 \u0026amp;\u0026amp; y%i==0)\n  {\n   hcf=i;\n  }\n }\n \n \/\/ Returnig hcf\n return hcf;\n}\n\nint calculatelcm(int x, int y, int h) \/\/ h is passed value of hcf\n{\n \/\/ Declaring variable lcm to store calculated lcm\n int lcm=1;\n \n \/\/ lcm is calculated by formula : hcf * lcm =1\n lcm = (x*y)\/h;\n \n \/\/ Returning lcm\n return lcm;\n}\n\nint main()\n{\n \/\/ Declaring variable \"a\" and \"b\" to input two numbers\n int a, b;\n \n \/* Declaring variable hcf=to hold hcf returned to it, \n lcm=to hold lcm returned to it *\/\n int hcf, lcm;\n \n \/\/ Inputting two numbers\n printf(\"Enter first number : \");\n scanf(\"%d\", \u0026amp;a);\n \n printf(\"Enter first number : \");\n scanf(\"%d\", \u0026amp;b);\n \n \/\/ Calling function calculatehcf\n hcf=calculatehcf(a, b);\n \n \/\/ Calling function calculatelcm\n lcm=calculatelcm(a, b, hcf);\n \n \/\/ Printing hcf and lcm\n printf(\"hcf = %d \",hcf);\n printf(\"\\nlcm = %d \",lcm);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p5\" name=\"p5\"\u003E5. Implement a function that takes two values of integer type and interchange them \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ 1. without using Third variable. You may use arithmetic operators\n\/\/ 2. With the use of third variable. You should not use arithmetic operator\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nvoid swap_without_third_variable(int a, int b)\n{\n \/\/ performing swapping\n a=a+b;\n b=a-b;\n a=a-b;\n \n \/\/ Printing interchange value\n printf(\"\\nInterchange value without use of third variable : a=%d, b=%d\", a, b);\n \n}\n\nvoid swap_with_third_variable(int a, int b)\n{\n \/\/ Declaring varibale swap to help in interchanging value\n int swap;\n \n \/\/ Performing swapping\n swap=a;\n a=b;\n b=swap;\n \n \/\/ Printing interchange value\n printf(\"\\nInterchange value without use of third variable : a=%d, b=%d\", a, b);\n}\n\nint main()\n{\n \/\/ Declaring variable a, b to input two numbers\n int a, b;\n \n \/\/ Inputting number\n printf(\"Enter value of a : \");\n scanf(\"%d\",\u0026amp;a);\n \n printf(\"Enter value of b : \");\n scanf(\"%d\",\u0026amp;b);\n \n \/\/ Printing original value\n printf(\"Orginal value a = %d, b = %d \",a, b);\n \n \/\/ Calling functions\n swap_without_third_variable(a, b);\n swap_with_third_variable(a, b);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 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\/6959814840319685669\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6959814840319685669"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6959814840319685669"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html","title":"C PROGRAMS : FUNCTION"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-3065824922547362513"},"published":{"$t":"2014-01-29T03:54:00.000-08:00"},"updated":{"$t":"2014-06-12T02:15:04.384-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"control sturctures"}],"title":{"type":"text","$t":"C PROGRAMS : ENCODE AND DECODE ( CIPHER )"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-encode-and-decode-cipher.html#cipher\" name=\"cipher\"\u003EProgram to encode and decode ( cipher )\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable for pt=plaint text, ct=cipher text\n char pt[20],ct[20];\n int l=0,i,j,k=0;\n int kl,key[20];\n printf(\"%d\",(-27%26));\n printf(\"Enter string:\");\n gets(pt);\n while(pt[l]!='\\0')\n l++;\n \n printf(\"Enter key length:\");\n scanf(\"%d\",\u0026amp;kl);\n printf(\"Enter key:\");\n for(i=0;i\u0026lt;kl;i++)\n {\n  scanf(\"%d\",\u0026amp;key[i]);\n }\n if(kl!=l)\n {\n for(i=kl;i\u0026lt;l;i++)\n {\n  if(k==kl)\n  {\n  k=k-kl;\n  key[i]=key[k];\n  k++;\n  }\n  else\n  {\n  key[i]=key[k];\n  k++;\n   }\n }\n }\n printf(\"Key Sequence: \");\n for(i=0;i\u0026lt;l;i++)\n {\n  printf(\"%d \",key[i]);\n }\n \n \/\/ Encrypting\n  for(i=0;i\u0026lt;l;i++)\n {\n  \/\/ For small letter\n  if(pt[i]\u0026gt;=97 \u0026amp;\u0026amp; pt[i]\u0026lt;=122)\n  ct[i]=(((pt[i]-97)+key[i])%26)+97; \n  \n  \/\/ For capital letter\n  else if(pt[i]\u0026gt;=65 \u0026amp;\u0026amp; pt[i]\u0026lt;=90)\n  ct[i]=(((pt[i]-65)+key[i])%26)+65;\n  \n  \/\/ For digits \n  else if(pt[i]\u0026gt;=48 \u0026amp;\u0026amp; pt[i]\u0026lt;=57)\n  ct[i]=(((pt[i]-48)+key[i])%10)+48;\n  \n  \/\/ For special Charactrer\n  else if(pt[i]\u0026gt;=33 \u0026amp;\u0026amp; pt[i]\u0026lt;=47)\n  ct[i]=(((pt[i]-33)+key[i])%15)+33;\n  \n  else if(pt[i]\u0026gt;=58 \u0026amp;\u0026amp; pt[i]\u0026lt;=64)\n  ct[i]=(((pt[i]-58)+key[i])%7)+58;\n  \n  else if(pt[i]\u0026gt;=91 \u0026amp;\u0026amp; pt[i]\u0026lt;=96)\n  ct[i]=(((pt[i]-91)+key[i])%6)+91;\n  \n  else if(pt[i]\u0026gt;=123 \u0026amp;\u0026amp; pt[i]\u0026lt;=126)\n  ct[i]=(((pt[i]-123)+key[i])%4)+123;\n  \n  \/\/ For space \n  else if(pt[i]==' ')\n  ct[i]=pt[i]+127+key[i]; \n}\n    \n \n printf(\"\\nEncrypted data: \");\n for(i=0;i\u0026lt;l;i++)\n {\n  printf(\"%c\",ct[i]);\n }\n \n \/\/ Decrypting\n for(i=0;i\u0026lt;l;i++)\n {\n  \/\/ For small letter\n  if(ct[i]\u0026gt;=97 \u0026amp;\u0026amp; ct[i]\u0026lt;=122)\n  {\n   if((((ct[i]-97)-key[i])%26)\u0026lt;0)\n   pt[i]=ct[i]-key[i]+26;\n   else\n    pt[i]=(((ct[i]-97)-key[i])%26)+97; \n  }\n  \n  \/\/ For capital letter\n  else if(ct[i]\u0026gt;=65 \u0026amp;\u0026amp; pt[i]\u0026lt;=90)\n  {\n   if((((ct[i]-65)-key[i])%26)\u0026lt;0)\n   pt[i]=ct[i]-key[i]+26;\n   else\n    pt[i]=(((ct[i]-65)-key[i])%26)+65; \n  }\n  \n  \/\/ For digits\n  else if(ct[i]\u0026gt;=48 \u0026amp;\u0026amp; pt[i]\u0026lt;=57)\n  {\n   if((((ct[i]-48)-key[i])%10)\u0026lt;0)\n   pt[i]=ct[i]-key[i]+10;\n   else\n    pt[i]=(((ct[i]-48)-key[i])%10)+48; \n \n      }\n      \n  \/\/ For special character\n  else if(ct[i]\u0026gt;=33 \u0026amp;\u0026amp; pt[i]\u0026lt;=47)\n  {\n   if((((ct[i]-33)-key[i])%15)\u0026lt;0)\n   pt[i]=ct[i]-key[i]+15;\n   else\n    pt[i]=(((ct[i]-33)-key[i])%15)+33; \n \n  }\n  \n   else if(ct[i]\u0026gt;=58 \u0026amp;\u0026amp; pt[i]\u0026lt;=64)\n  {\n   if((((ct[i]-58)-key[i])%7)\u0026lt;0)\n   pt[i]=ct[i]-key[i]+7;\n   else\n    pt[i]=(((ct[i]-58)-key[i])%7)+58; \n  }\n  \n   else if(ct[i]\u0026gt;=91 \u0026amp;\u0026amp; pt[i]\u0026lt;=96)\n  {\n   if((((ct[i]-91)-key[i])%6)\u0026lt;0)\n   pt[i]=ct[i]-key[i]+6;\n   else\n    pt[i]=(((ct[i]-91)-key[i])%6)+91; \n  }\n  \n   else if(ct[i]\u0026gt;=123 \u0026amp;\u0026amp; pt[i]\u0026lt;=126)\n  {\n   if((((ct[i]-123)-key[i])%4)\u0026lt;0)\n   pt[i]=ct[i]-key[i]+4;\n   else\n    pt[i]=(((ct[i]-123)-key[i])%4)+123; \n  }\n  \n  \/\/ For space\n  else\n  pt[i]=ct[i]-127-key[i];\n  \n }\n \n printf(\"\\nActual Data: \");\n for(i=0;i\u0026lt;l;i++)\n {\n  printf(\"%c\",pt[i]);\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/3065824922547362513\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-encode-and-decode-cipher.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/3065824922547362513"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/3065824922547362513"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-encode-and-decode-cipher.html","title":"C PROGRAMS : ENCODE AND DECODE ( CIPHER )"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-5651101685133285199"},"published":{"$t":"2014-01-29T03:48:00.000-08:00"},"updated":{"$t":"2014-04-16T01:07:25.463-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"control sturctures"}],"title":{"type":"text","$t":"C PROGRAMS : CONTROL STRUCTURES"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : CONTROL STRUCTURES\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html#21\" name=\"21\"\u003E21.Program to award Grades according to the following: \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\n80% and above GRADE A\n70 to 79%  GRADE B\n60 to 69%  GRADE C\n50 to 59  GRADE D\nLess than 50% FAILED\n\nAssume maximum marks for each subject is 100. \nYou have to take marks input of 5 subject\n*\/\n\n\/\/ Using if-else\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable for marks\n int m1,m2,m3,m4,m5;\n \n \/\/ Declaring variable for p=percentage\n int p;\n \n \/\/ Inputing marks\n printf(\"Enter marks of 5 subjects:\");\n scanf(\"%d %d %d %d %d\",\u0026amp;m1,\u0026amp;m2,\u0026amp;m3,\u0026amp;m4,\u0026amp;m5);\n \n \/\/ Calculating and displaying percentage marks scored\n p=(m1+m2+m3+m4+m5)\/5;\n printf(\"Percentage : %d\\n\",p);\n \n \/\/ Determining Grades and Displaying it\n if(p\u0026lt;50)\n printf(\"Failed\");\n else if(p\u0026gt;=50 \u0026amp;\u0026amp; p\u0026lt;=59)\n printf(\"Grade D\");\n else if(p\u0026gt;=60 \u0026amp;\u0026amp; p\u0026lt;=69)\n printf(\"Grade C\");\n else if(p\u0026gt;=70 \u0026amp;\u0026amp; p\u0026lt;=79)\n printf(\"Grade B\");\n else\n printf(\"Grade A\");\n  \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html#22\" name=\"22\"\u003E22.Grade Program without using if-else statement \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable for marks\n int m1,m2,m3,m4,m5;\n \n \/\/ Declaring variable for p=percentage\n int p,i,g;\n \n \/\/ Inputing marks\n printf(\"Enter marks of 5 subjects:\");\n scanf(\"%d %d %d %d %d\",\u0026amp;m1,\u0026amp;m2,\u0026amp;m3,\u0026amp;m4,\u0026amp;m5);\n \n \/\/ Calculating and displaying percentage marks scored\n p=(m1+m2+m3+m4+m5)\/5;\n printf(\"Percentage : %d\\n\",p);\n \n \/\/ Determining grades and Displaying it\n while(p\u0026lt;50)\n {\n  printf(\"Failed\");\n  break;\n }\n while(p\u0026gt;=50 \u0026amp;\u0026amp; p\u0026lt;=59)\n {\n  printf(\"Grade D\");\n  break;\n }\n while(p\u0026gt;=60 \u0026amp;\u0026amp; p\u0026lt;=69)\n {\n  printf(\"Grade C\");\n  break;\n }\n while(p\u0026gt;=70 \u0026amp;\u0026amp; p\u0026lt;=79)\n {\n  printf(\"Grade B\");\n  break;\n }\n while(p\u0026gt;=80)\n {\n  printf(\"Grade A\");\n  break;\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html#23\" name=\"23\"\u003E23.Program to calculate the sum of individual digits of a number \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable for n=number, d=digit\n int n, d, sum=0;\n \n \/\/ Inputing number\n printf(\"Enter number: \");\n scanf(\"%d\",\u0026amp;n);\n \n \/\/ Determing sum of digits\n while(n!=0)\n {\n  d=n%10;  \/\/ Extracting last digit of a number\n  sum=sum+d; \/\/ Calculating digit sum\n  n=n\/10;  \/\/ Extracting first two digits \n  \n }\n \n \/\/ Displaying sum of digits\n printf(\"Sum of digits : %d\",sum);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html#24\" name=\"24\"\u003E24.Program to determine whether a given year is leap year or not \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable for y=year\n int y;\n \n \/\/ Inputing year\n printf(\"Enter year to check leap year or not: \");\n scanf(\"%d\",\u0026amp;y);\n \n \/\/ Determining and displaying whether leap year or not\n if(y%4==0)\n {\n  if(y%100==0 \u0026amp;\u0026amp; y%400!=0)\n  printf(\"Century year, But not a leap year\");\n  else\n  printf(\"Leap year\");\n }\n else\n printf(\"Not a Leap Year\");\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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\/5651101685133285199\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/5651101685133285199"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/5651101685133285199"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html","title":"C PROGRAMS : CONTROL STRUCTURES"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-2589893277001027602"},"published":{"$t":"2014-01-29T03:36:00.000-08:00"},"updated":{"$t":"2014-04-16T01:07:30.520-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"control sturctures"}],"title":{"type":"text","$t":"C PROGRAMS : CONTROL STRUCTURES"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : CONTROL STRUCTURES\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#p16\" name=\"p16\"\u003E17.Program to print the fibonacii series till which user wishes \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\n Fibonacii series: Fibonacii series is one in which the nth term is \n sum of (n-1)th term and (n-2)th term.\n The first two numbers of series are 0 and 1\n For example: 0 1 1 2 3 5 8 13 21 and so on\n *\/\n \n #include\u0026lt;stdio.h\u0026gt;\n #include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n int main()\n {\n  \/* Declaring variable for n=number, f=first, s=second, \n  t=third number, i=to iterate the loop *\/\n  int n,f,s,t,i;\n  \n  \/\/ Inputing number till where fibonacci series is to be displayed\n  printf(\"Enter the number till which you want to see fibonacci series:\");\n  scanf(\"%d\",\u0026amp;n);\n  \n  \/\/ Determining and displaying fibonacii series\n  printf(\"Fibonacii Series: \");\n  \n  f=0;\n  s=1;\n  printf(\"%d %d \",f,s);\n  for(i=3;i\u0026lt;=n;i++)\n  {\n   t=f+s;\n   printf(\"%d \",t);\n   f=s;\n   s=t;\n  }\n  getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n  return 0;\n }\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#p17\" name=\"p17\"\u003E17. Program to determine whether entered character is capital case letter, small case letter, a digit or a special symbol\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable for c=character\n char c;\n \n \/\/ Inputing character\n printf(\"Enter any character: \");\n scanf(\"%c\",\u0026amp;c);\n \n if(c\u0026gt;=65 \u0026amp;\u0026amp; c\u0026lt;=90)\n printf(\"Character is Upper Case Letter\");\n else if(c\u0026gt;=97 \u0026amp;\u0026amp; c\u0026lt;=122)\n printf(\"Character is Lower Case Letter\");\n else if(c\u0026gt;=48 \u0026amp;\u0026amp; c\u0026lt;=57)\n printf(\"Character is a Digit\");\n else\n printf(\"Character is Special Symbol\");\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#p18\" name=\"p18\"\u003E18.Program to find whether a number is Perfect Square or Not \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\nA perfect square is a number that can be expressed as the product of two equal integers.\n\n9\n9 is a perfect square becuase it can be expressed as 3 * 3 (product of two equal integers)\n16\n16 is a perfect square becuase it can be expressed as 4 * 4 (product of two equal integers)\n25\n25 is a perfect square becuase it can be expressed as 5 * 5 (product of two equal integers)\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/Declaring variable for n=number\n int n;\n \n \/\/ Declaring variable for r=remainder, q=uotient, i=to iterate the loop\n int r=0,q=0,i,flag=0;\n \n \/\/ Inputting Number\n printf(\"Enter any numbre: \");\n scanf(\"%d\",\u0026amp;n);\n \n \/\/ Determin whether Numbr is Perfect Square or Not\n for(i=1;i\u0026lt;=n;i++)\n {\n  r=n%i;\n  q=n\/i;\n  if(r==0 \u0026amp;\u0026amp; i==q)\n  {\n   flag=1;\n   break;\n  }\n }\n \n \/\/ Displaying Result\n if(flag==1)\n printf(\"Number is Perfect Square\");\n else\n printf(\"Number is not Perfect Square\");\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#p19\" name=\"p19\"\u003E19.Program to print (list) Perfect Square Number between any two number and display it in the format \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/* Declaring variable for r=remainder, q=uotient, i,\n m=to iterate the loops, f1=Another flag variable *\/\n int r=0, q=0, i, flag=0, f1=0, m;\n \n \/\/ Delcaring variable for s=start point, e=endpoint\n int s,e;\n \n \/\/ Inputting start point and end point\n printf(\"Enter from where you want to list perfect Number:\");\n scanf(\"%d\",\u0026amp;s);\n printf(\"Enter till where you want to list perfect Number:\");\n scanf(\"%d\",\u0026amp;e);\n \n \/\/ Determin Number is Perfect or Not\n for(m=s;m\u0026lt;=e;m++)\n {\n  flag=0;\n for(i=1;i\u0026lt;=m;i++)\n {\n  r=m%i;\n  q=m\/i;\n  if(r==0 \u0026amp;\u0026amp; i==q)\n  {\n   f1=1;\n   flag=1;\n   break;\n  }\n }\n \n \/\/ Displaying Perfect Square Numbre in the given format\n if(flag==1)\n printf(\"%d is a Perfect Square because it can be expressed as: %d * %d \\n\",m,i,i);\n  }\n  \n \/* Checking if any Perfect Square Number exist and if not \n then displaying appropriate message *\/   \n if(f1==0)\n printf(\"No Perfect Square Number exist\");\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#p20\" name=\"p20\"\u003E20. Program for Bank account Handling \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre style=\"text-align: left;\"\u003E\u003Cspan style=\"color: blue;\"\u003EA customer maintains a saving account in a bank. The bank provide an interest rate of \nsimple interest of 4% per annum. Write a program displaying a menu to let the user enter \nthe coice as follows: \n1 : Deposit an amount A\n2 : Withdrawl of amount A\n3 : Displaying the balance amount\n4 : Calculating interest for d days on balance amount\n5 : Exit\nFix initial balance amount = 1000\n*\/\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable for a=amount, ba=balance amount, si=simple interest\n float a, ba=1000, si;\n \n \/* Declaring variable for ch=choice, d=day, ans=checks if user \n want to enter another query or choice *\/\n int ch, d,ans;\n \n \/\/ Displaying choices\n printf(\"Bank Queries:\\n\");\n printf(\"1 : Deposit an amount\\n\");\n printf(\"2 : Withdrawl of amount\\n\");\n printf(\"3 : Displaying the balance amount\\n\");\n printf(\"4 : Calculating interest for d days on balance amount\\n\");\n printf(\"5 : exit\\n\\n\");\n \n do\n {\n \/\/ Inputing choices\n printf(\"Enter your query:\");\n scanf(\"%d\",\u0026amp;ch);\n \n \/\/ Performing various bank queries\n switch(ch)\n {\n  case 1:\n   \/\/ Inputing deposit amount\n   printf(\"Enter amount to be deposited:\");\n   scanf(\"%f\",\u0026amp;a);\n   ba=ba+a;\n   break;\n  case 2:\n   \/\/ Inputing withdrawl amount\n   printf(\"Enter withdrawl amount:\");\n   scanf(\"%f\",\u0026amp;a);\n   ba=ba-a;\n   break;\n  case 3:\n   printf(\"Balance Amount: %f\\n\",ba);\n   break;\n  case 4:\n   \/\/ Inputing days\n   printf(\"Enter Days for which you want to calculate interest:\");\n   scanf(\"%d\",\u0026amp;d);\n   \n   \/\/ Calculating simple interest\n   si=(a*0.04*d)\/100;\n   printf(\"Simple interest=%f\\n\",si);\n   ba=ba+si;\n   break;\n  case 5:\n   printf(\"Press any key to exit\");\n   getch();\n   exit(0);\n   break;\n   default:\n    printf(\"Wrong Entry\");\n }\n printf(\"Do you want to enter another query: 1-yes, 2-no : \");\n scanf(\"%d\",\u0026amp;ans);\n  }while(ans==1);\n \n printf(\"Press any key to exit\");\n\u0026nbsp;\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre style=\"text-align: left;\"\u003E\u003Cspan style=\"color: blue;\"\u003E getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"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\/2589893277001027602\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/2589893277001027602"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/2589893277001027602"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html","title":"C PROGRAMS : CONTROL STRUCTURES"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-2187229094122062898"},"published":{"$t":"2014-01-29T03:08:00.000-08:00"},"updated":{"$t":"2014-04-16T01:07:34.961-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"control sturctures"}],"title":{"type":"text","$t":"C PROGRAMS : CONTROL STRUCTURES"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : CONTROL STRUCTURES\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.html#p11\" name=\"p11\"\u003E11.Program to find whether a given number is Prime or Not \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/* Declaring variable for n=number, c=counter variable:holds \n number of factor of 'n' *\/\n int n,c=0, i;\n \n \/\/ Inputting number\n printf(\"Enter number to check whether Prime or Not:\");\n scanf(\"%d\",\u0026amp;n);\n\n \/\/ Checking whether number valid or not\n if(n\u0026gt;0)\n {\n  \n \/\/ Checking whether number is prime or not \n for(i=1;i\u0026lt;=n;i++)\n {\n  if(n%i==0)\n  c=c+1;\n }\n \n if(c==2)\n printf(\"Prime Number\");\n else\n printf(\"Not a Prime Number\");\n }\n \n else \n printf(\"Not a valid Number\");\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.html#p12\" name=\"p12\"\u003E12.Program to print ( list ) all the prime number between 1 to n \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/* Declaring variable for n=number, c=counter variable:holds \n number of factor of 'n' *\/\n int n,c, i,j;\n \n \/\/ Inputting number\n printf(\"Enter number till which you want to list prime number:\");\n scanf(\"%d\",\u0026amp;n);\n\n \/\/ Checking whether number valid or not\n \n if(n\u0026gt;0)\n {\n  printf(\"List of Prime Numbers:\");\n \/\/ Checking whether number is prime or not \n for(i=1;i\u0026lt;=n;i++)\n {\n  c=0;\n  for(j=1;j\u0026lt;=i;j++)\n  {\n  if(i%j==0)\n  c=c+1;\n  }\n if(c==2)\n printf(\"%d \",i);\n }\n \n }\n else \n printf(\"Not a valid Number\");\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.html#p13\" name=\"p13\"\u003E13.Program to print (list) Palindrome number from 10 to n\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Palindrome Number: Reverse of Number = Number\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n\/*declaring variable for num=user wish, i=acts as number, n=to copy number, \nd=digit, rev=reverse of number *\/\nint num,n,d=0,rev,i;\n\n\/\/ Inputting number\nprintf(\"Enter number till which you want to list Palindrome Number:\");\nscanf(\"%d\",\u0026amp;num);\n\nprintf(\"List of Palindrome Number:\");\nfor(i=10;i\u0026lt;=num;i++)\n{\n \/\/ copying number in n\n n=i;\n rev=0;\n\/\/ Determining whether number is palindrome or not\nwhile(n!=0)\n{\n           d=n%10;\n           rev=rev*10+d;\n           n=n\/10;\n           }\n           \n           \/\/ Displaying Whether number is palindrome or not\n           if(i==rev)\n           printf(\"%d \",i);\n       }\n      \n     getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n     return 0;\n     \n     }\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.html#p14\" name=\"p11\"\u003E14.Program to print (list) Armstrong Number between two given numbers \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Armstrong Number: Sum of cube of digit=Number\n\n#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n\/*declaring variable for s=start point, e=end point, i=acts as number, \nn=to copy number, d=digit, s=sum *\/\nint s,e,n,d=0,sum,i;\n\n\/\/ Inputting number\nprintf(\"Enter form where you want to list Armstrong Number:\");\nscanf(\"%d\",\u0026amp;s);\nprintf(\"Enter number till which you want to list Armstrong Number:\");\nscanf(\"%d\",\u0026amp;e);\n\nprintf(\"List of Armstrong Number:\");\nfor(i=s;i\u0026lt;=e;i++)\n{\n \/\/ copying number in n\n n=i;\n sum=0;\n \n\/\/ Determining whether number is pallindrome or not\nwhile(n!=0)\n{\n           d=n%10;\n           sum=sum+(d*d*d);\n           n=n\/10;\n }\n           \n           \/\/ Displaying Whether number is pallindrome or not\n           if(i==sum)\n           printf(\"%d \",i);\n }\n      \n     getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n     return 0;\n     \n}\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.html#p15\" name=\"p11\"\u003E15.Program to print the factor of a given number \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable for n=numbre,i=to iterate the loop\n int n,i;\n \n \/\/ Inputing number\n printf(\"Enter any number:\");\n scanf(\"%d\",\u0026amp;n);\n \n \/\/ Determining and Displaying factors\n printf(\"Listing Factors of %d :\",n);\n for(i=1;i\u0026lt;=n;i++)\n {\n  if(n%i==0)\n  printf(\"%d \",i);\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 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\/2187229094122062898\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/2187229094122062898"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/2187229094122062898"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.html","title":"C PROGRAMS : CONTROL STRUCTURES"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-5145926858863194990"},"published":{"$t":"2014-01-29T02:51:00.000-08:00"},"updated":{"$t":"2014-04-16T01:07:38.941-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"control sturctures"}],"title":{"type":"text","$t":"C PROGRAMS : CONTROL STUCTURES"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : CONTROL STRUCTURES\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p6\" name=\"p6\"\u003E6. Program for finding the factorial of a number\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n\n\/\/ Variable for n=number and fact=factorial\nint n,fact=1;\n\n\/\/ Inputing number whose factorial is to be found\nprintf(\"Enter number:\");\nscanf(\"%d\",\u0026amp;n);\n\n\/\/ Calculating Factorial\nwhile(n\u0026gt;=1)\n{\nfact=fact*n;\nn--;\n}\n\n\/\/ Diaplaying Factorial\nprintf(\"%d\",fact);\ngetch (); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p7\" name=\"p7\"\u003E7. Program to find whether the entered character is vowel or not using if else\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable where c=character\n char c;\n \n \/\/ Inputing character\n printf(\"Enter character:\");\n scanf(\"%c\",\u0026amp;c);\n \n \/\/ Determing whether entered character is vowel or not\n if(c=='a' || c=='e' || c=='i' || c=='o' || c=='u' || c=='A' || \n c=='E' || c=='I' || c=='O' || c=='U')\n {\n printf(\"Entered character is vowel\");\n }\n else\n printf(\"Eneterd character is a constant\");\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p8\" name=\"p8\"\u003E8. Program to find whether the entered character is vowel or not using switch case\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable where c=character\n char c;\n \n \/\/ Inputing character\n printf(\"Enter character:\");\n scanf(\"%c\",\u0026amp;c);\n \n\/\/ Determing whether entered character is vowel or not\nswitch(c)\n{\n case 'a': case 'A':\n case 'e': case 'E':\n case 'i': case 'I':\n case 'o': case 'O':\n case 'u': case 'U': \n printf(\"Character is vowel\");\n break;\n default:\n  printf(\"Character is a constant\");\n}\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p9\" name=\"p9\"\u003E9. Program to print the table of a given number till the user wishes\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring Variable for n=number, tw=till where he wants to print the table\n int i, n, tw;\n \n \/\/ Inputting number and user wish\n printf(\"Enter the number whose table you want to generate:\");\n scanf(\"%d\",\u0026amp;n);\n printf(\"Enter till where you want to generate table:\");\n scanf(\"%d\",\u0026amp;tw);\n \n \/\/ Displaying table\n for(i=1;i\u0026lt;=tw;i++)\n {\n printf(\"%d * %d = %d \\n\",n,i,n*i);\n }\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p10\" name=\"p10\"\u003E10. Program to sum up all the integer numbers input at run time until zero is entered\u003C\/a\u003E \u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Declaring variable for n=number, s=sum\n int n,s=0;\n \n do\n {\n \/\/ Inputting number\n printf(\"Enter any number:\");\n scanf(\"%d\",\u0026amp;n);\n \n  \/\/ Calculating sum until zero is not entered\n  s=s+n;\n }while(n!=0);\n \n \/\/ Displaying sum of all integers entered\n printf(\"Sum of all integers=%d\",s);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/5145926858863194990\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/5145926858863194990"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/5145926858863194990"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html","title":"C PROGRAMS : CONTROL STUCTURES"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-6247751899627272956"},"published":{"$t":"2014-01-29T02:31:00.000-08:00"},"updated":{"$t":"2014-04-16T01:07:45.508-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"control sturctures"}],"title":{"type":"text","$t":"C PROGRAMS : CONTROL STRUCTURES"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : CONTROL STRUCTURES\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p1\" name=\"p1\"\u003E1. Program to multiply 2 number without using * operator\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Variable for 2 numbers, and for result\n int a, b, r=0;\n \n \/\/ Inputting 2 integers\n printf(\"Enter two integers:\");\n scanf(\"%d %d\",\u0026amp;a,\u0026amp;b);\n \n \/\/ Multiplying 2 numbers\n if(a\u0026gt;b)\n {\n while(b)\n {\n  r=r+a;\n  b--;\n }\n }\n else\n {\n while(a)\n {\n  r=r+b;\n  a--;\n }\n }\n  \n \/\/ Displaying result\n printf(\"Product of two number:%d\",r);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p2\" name=\"p2\"\u003E2. Program to determine armstrong number\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n\/\/ variable for a=numbern, n=to copy number, d=digit\nint a,n,d=0,sum=0;\n\n\/\/ Inputting number\nprintf(\"Enter any number to determine whether it is armstorng or not:\");\nscanf(\"%d\",\u0026amp;a);\n\n\/\/ copying number in n\nn=a;\n\n\/\/ Determining whether number is armstrong or not\nwhile(n!=0)\n{\n           d=n%10;\n           sum=sum+d*d*d;\n           n=n\/10;\n}\n           \n\/\/ Displaying Whether number is armstrong or not\nif(a==sum)\nprintf(\"Armstron no\");\nelse\nprintf(\"not armstrong\");\n   \ngetch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nreturn 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p3\" name=\"p3\"\u003E3. Program to input time in seconds and convert them into hours, minutes and seconds and display it\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/* Variable for time in second, converted in hour, converted in minutes \n and converted in seconds, r for remainder *\/\n int ts, ch=0, cm=0, cs, r=0;\n \n \/\/ Inputting time in second\n printf(\"Enter time in seconds:\");\n scanf(\"%d\", \u0026amp;ts);\n \n \/\/ Converting in hours, minutes and seconds \n if(ts\u0026lt;60)\n cs=ts;\n \n else if(ts\u0026lt;3600)\n {\n cm=ts\/60;\n cs=ts%60; \n }\n \n else if(ts\u0026gt;3600)\n {\n ch=ts\/3600;\n r=ts%3600;\n if(r\u0026gt;60)\n {\n  cm=r\/60;\n  r=r%60;\n }\n if(r\u0026lt;60)\n cs=r;\n }\n \n \/\/ Displaying seconds in hour, minutes and seconds\n printf(\"Time in hour minutes and seconds: %d\/%d\/%d\",ch,cm,cs);\n\u0026nbsp;\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n \n}\u003C\/span\u003E\n\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p4\" name=\"p41\"\u003E4. Program to determine palindrome number\u003C\/a\u003E \u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n\/\/ variable for a=number, n=to copy number, d=digit, rev=reverse of number\nint a,n,d=0,rev=0;\n\n\/\/ Inputting number\nprintf(\"Enter any number to determine whether it is Palindrome or not:\");\nscanf(\"%d\",\u0026amp;a);\n\n\/\/ copying number in n\nn=a;\n\n\/\/ Determining whether number is palindrome or not\nwhile(n!=0)\n{\n           d=n%10;\n           rev=rev*10+d;\n           n=n\/10;\n           }\n           \n           \/\/ Displaying Whether number is palindrome or not\n           if(a==rev)\n           printf(\"Palindrome number\");\n           else\n           printf(\"Not a Palindrome Number\");\n          \n     getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n     return 0;\n     \n     }\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p5\" name=\"p5\"\u003E5. Program showing the use of goto statement\u003C\/a\u003E \u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\nint i=0;\u003C\/span\u003E\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cstdio .h=\"\"\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003Egoto a;\nna:       \nprintf(\"Not allowed = %d\\n\",i);\na:\n    for(i=i+1;i\u0026lt;=35;i++)\n    {\n        if(i==15||i==30)\n        goto na;\n        else\n        printf(\"Allowed =%d\\n\",i);\n    }\n        \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n     \n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/6247751899627272956\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#comment-form","title":"2 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6247751899627272956"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/6247751899627272956"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html","title":"C PROGRAMS : CONTROL STRUCTURES"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"2"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-132005681766684109"},"published":{"$t":"2014-01-29T02:05:00.000-08:00"},"updated":{"$t":"2014-04-16T01:08:17.405-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Fundamental"}],"title":{"type":"text","$t":" C PROGRAMS : FUNDAMENTALS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : FUNDAMENTALS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p11\" name=\"p11\"\u003E11. Program to input a number and find whether it is even or odd\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variale \"n\" to store input number\n int n,r;\n \n \/\/ Inputting number\n printf(\"Enter a number : \");\n scanf(\"%d\", \u0026amp;n);\n \n \/\/ Checking if input number is ever or odd\n if(n%2==0)\n printf(\"Entered number is even\");\n else\n printf(\"Entered number is odd\");\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p12\" name=\"p12\"\u003E12. Program to find biggest of four no by using ternary numbers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable a, b, c, d to store 4 numbers input by user\n int a,b,c,d;\n \n \/\/ Declaring variable big to store the biggest value\n int big;\n\n \/\/ Inputting number\n printf(\"Enter first number : \");\n scanf(\"%d\",\u0026amp;a);\n printf(\"Enter second number : \");\n scanf(\"%d\",\u0026amp;b);\n printf(\"Enter thirda number : \");\n scanf(\"%d\",\u0026amp;c);\n printf(\"Enter fourth number : \");\n scanf(\"%d\",\u0026amp;d);\n \n \/\/ Determining biggest number\n big=(a\u0026gt;b)?(a\u0026gt;c)?(a\u0026gt;d)?a:d:(c\u0026gt;d)?c:d:(b\u0026gt;c)?(b\u0026gt;d)?b:d:(c\u0026gt;d)?c:d;\n\n \n \/\/ Printing smallest number\n printf(\"Biggest of four number = %d\",big);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p13\" name=\"p13\"\u003E13. Program to print smallest of four no by using ternary operators\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n\n\u003C\/span\u003E\u003Cspan 0=\"\" a:d:=\"\" a=\"\" b:d:=\"\" b=\"\" c:d:=\"\" c:d=\"\" c=\"\" d=\"\" four=\"\" getch=\"\" mallest=\"\" number=\"%d\" of=\"\" pre=\"\" printf=\"\" printing=\"\" return=\"\" small=\"\" smallest=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003Eint main()\n{\n \/\/ Declaring variable a, b, c, d to store 4 numbers input by user\n int a,b,c,d;\n \n \/\/ Declaring variable small to store the smallest value\n int small;\n\n \/\/ Inputting number\n printf(\"Enter first number : \");\n scanf(\"%d\",\u0026amp;a);\n printf(\"Enter second number : \");\n scanf(\"%d\",\u0026amp;b);\n printf(\"Enter thirda number : \");\n scanf(\"%d\",\u0026amp;c);\n printf(\"Enter fourth number : \");\n scanf(\"%d\",\u0026amp;d);\n \n \/\/ Determining smallest number\n small=(a\u0026lt;b)?(a\u0026lt;c)?(a\u0026lt;d)?a:d:(c\u0026lt;d)?c:d:(b\u0026lt;c)?(b\u0026lt;d)?b:d:(c\u0026lt;d)?c:d;\n \n \/\/ Printing smallest number\n printf(\"Smallest of four number = %d\",small);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003Cb\u003E\n\u003C\/b\u003E\u003C\/span\u003E\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p14\" name=\"p14\"\u003E14. Program to accept a year and check the given year is leap or not by using ternary \u003C\/a\u003E \u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main()\n{\n \/\/ Declaring variable \"y\" to input year and \"leap\" to determine leap year\n int y,leap;\n \n \/\/ Inputting year\n printf(\"Enter any year : \");\n scanf(\"%d\",\u0026amp;y);\n \n \/\/ Checking if leaf year or not\n leap=(y%400==0)?:(y%100!=0)?(y%4==0)?1:0:0;\n\n if(leap==1)\n printf(\"The given year is leap year\");\n else\n printf(\"The given year is not leap year\");\n\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p15\" name=\"p15\"\u003E15. Program to find area of a triangle when there sides are given\u003C\/a\u003E \u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cstdio .h=\"\"\u003E\u003Cconio .h=\"\"\u003E\u003Cc 0=\"\" a=\"\" area=\"\" b=\"\" c=\"\" calculating=\"\" else=\"\" getch=\"\" inding=\"\" is=\"\" not=\"\" possible=\"\" pre=\"\" printf=\"\" printing=\"\" rea=\"%.2f\" return=\"\" s=\"(a+b+c)\/2;\"\u003E\u003Cspan style=\"color: blue;\"\u003E# include \u0026lt;stdio.h\u0026gt;\n# include \u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\nint main( )\n {\n \/\/ Declaring variable a, b, c = to store three sides of triangle\n int a,b,c;\n \n \/\/ Declaring variable s = mid value\n float s, area;\n\n \/\/ Inputing sides of triangle\n printf(\"Enter there sides of the triangle : \");\n scanf(\"%d%d%d\",\u0026amp;a,\u0026amp;b,\u0026amp;c);\n \n \/\/ Checking if finding area is possible or not\n if((a+b)\u0026lt;c||(b+c)\u0026lt;a||(a+c)\u0026lt;b)\n printf(\"Finding area is not possible\");\n \n \/\/ Calculating area\n else\n {\n s=(a+b+c)\/2;\n area=sqrt(s*(s-a)*(s-b)*(s-c));\n }\n \n \/\/ Printing area\n printf(\"Area=%.2f\",area);\n \n getch( ); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/c\u003E\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/132005681766684109\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/132005681766684109"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/132005681766684109"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html","title":" C PROGRAMS : FUNDAMENTALS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-792147153293143781"},"published":{"$t":"2014-01-29T01:28:00.000-08:00"},"updated":{"$t":"2014-04-16T01:08:21.293-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Fundamental"}],"title":{"type":"text","$t":"C PROGRAMS : FUNDAMENTALS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : FUNDAMENTALS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p6\" name=\"p6\"\u003E6. Program to find the average of three numbers with input values as integer and output value (avg) as float\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n    int a, b, c;\n    float avg;\n    \n    printf(\"Enter any three numbers \");\n    scanf(\"%d %d %d\", \u0026amp;a, \u0026amp;b, \u0026amp;c);\n    avg = ( (float)a + (float)b + (float)c ) \/ 3; \n    \/* we have type casted integer to float as a, b, c, 3 all are integer type and\u003C\/span\u003E\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cstdio .h=\"\"\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\u0026nbsp;    \u003C\/span\u003E\u003C\/conio\u003E\u003C\/stdio\u003E\u003Cspan style=\"color: blue;\"\u003Einteger \/ integer gives the result integer. *\/\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cstdio .h=\"\"\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E    printf(\"Average=%f\", avg);\n    getch();\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p7\" name=\"p7\"\u003E7. Program to find the area of a right angled triangle based on base and height values\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n    float h, b, area;\n    \n    printf(\"Enter base \");\n    scanf(\"%f\",\u0026amp;b);\n    printf(\"Enter height \");\n    scanf(\"%f\", \u0026amp;h);\n    area=(0.5)*b*h;\n    printf(\"Area of right angled triangle= %f\", area);\n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p8\" name=\"p8\"\u003E8. Program to find or obtain the sum of square of two floating point numbers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n    float a, b, sum;\n    \n    printf(\"Enter first number \");\n    scanf(\"%f\", \u0026amp;a);\n    printf(\"Enter second number \");\n    scanf(\"%f\", \u0026amp;b);\n    printf(\"Square of first number = %f\", a*a);\n    printf(\"\\n Square of second number = %f\", b*b);\n    sum = (a*a + b*b); \n    printf(\"\\n Sum of square = %f\", sum);\n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p9\" name=\"p9\"\u003E9. Program to find the simple interest and total amount based on interest\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/* Variables for principal amount, rate of interest, time duration,\n  simple interest and total amount *\/\n int pa, ri, t, si,ta;\n \n \/\/ Inputting values\n printf(\"Enter principal amount:\");\n scanf(\"%d\", \u0026amp;pa);\n printf(\"Enter rate of interest:\");\n scanf(\"%d\", \u0026amp;ri);\n printf(\"Enter time duration:\");\n scanf(\"%d\", \u0026amp;t);\n \n \/\/ calculating simple interest and total amount\n si = (pa*ri*t)\/100;\n ta = si + pa;\n \n \/\/ displaying simple interest and total amount\n printf(\"Simple interest: %d and total amount: %d\", si,ta);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cstdio .h=\"\"\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p10\" name=\"p10\"\u003E 10. Program to enter 10 digit number and displaying it in the given format where first 3 digit refer to area code, next three digit to exchange code and remaining to number.Program to enter 10 digit number and displaying it in the given format where first 3 digit refer to area code, next three digit to exchange code and remaining to number.\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E\/*\u003C\/span\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003EInput\/output:\nEnter 10 digit number: 9876543210\nYou entered: 9876543210\nArea code: 987\nExchange code: 654\nNumber: 3210\nThe complete telephone number: (987)654-3210\n\n*\/\u003C\/span\u003E\n\u003C\/pre\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n int a,b,c;\n \n \/\/ Inputting Telephone number\n printf(\"Enter ten digit telephone no.\");\n scanf(\"%3d %3d %4d\",\u0026amp;a,\u0026amp;b,\u0026amp;c);\n \n \/\/ Displaying telephone number in given format\n printf(\"You entered:%d%d%d\\n\",a,b,c);\n printf(\"Area code:%d\\n\",a);\n printf(\"Exchange code:%d\\n\",b);\n printf(\"Number:%d\\n\",c);\n printf(\"The complete telephone number:(%d)%d-%d\",a,b,c);\n \n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/792147153293143781\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/792147153293143781"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/792147153293143781"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html","title":"C PROGRAMS : FUNDAMENTALS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-9059165963397579917"},"published":{"$t":"2014-01-28T06:29:00.001-08:00"},"updated":{"$t":"2014-07-09T13:54:47.875-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Contents"}],"title":{"type":"text","$t":"C PROGRAMS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\nHere more than 100 basic \u003Cspan style=\"color: lime;\"\u003Ec programs\u003C\/span\u003E are listed for practice. I have divided these \u003Cspan style=\"color: lime;\"\u003Ec programs\u003C\/span\u003E according to the topics for easier navigation and understanding.\u003Cbr \/\u003E\n\u003Cbr \/\u003E\nRequest : Please Link to this post and share this on social networking sites if you find it useful.\u003Cbr \/\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\" name=\"contents\" style=\"font-weight: normal;\"\u003E\u003Cspan style=\"color: yellow;\"\u003ECONTENTS\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003Cdiv\u003E\n\u003Cul style=\"text-align: left;\"\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#fundamentals\"\u003EC Fundamentals\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#controlstructures\"\u003EControl Structures\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#patterns\"\u003EPatterns\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#functions\"\u003EFunctions\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#recursion\"\u003ERecursion\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#arrays\"\u003EArrays\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#strings\"\u003EString\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#pointers\"\u003EPointers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#dms\"\u003EDynamic Memory Allocation\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ul\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#fundamentals\" name=\"fundamentals\"\u003E\u003Cspan style=\"color: yellow; font-weight: normal;\"\u003EFUNDAMENTALS\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003C\/div\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\"\u003EBack to contents\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv\u003E\n\u003Col style=\"text-align: left;\"\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p1\"\u003EA simple program for printing a line of text\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p2\"\u003EProgram to input integer number and display it\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p3\"\u003EProgram to add, subtract, multiply and divide two numbers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p4\"\u003EProgram to subtract two numbers without using arithmetic operator ( - )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p5\"\u003EProgram to find greatest between three numbers using conditional operator ( ? : )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p6\"\u003EProgram to find the average of three numbers with input values as integer and output value (avg) as float\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p7\"\u003EProgram to find the area of a right angled triangle based on base and height values\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p8\"\u003EProgram to find or obtain the sum of square of two floating point numbers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p9\"\u003EProgram to find the simple interest an total amount based on interest\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals1.html#p10\"\u003EProgram to enter 10 digit number and displaying it in the given format where first 3 digit refer to area code, next three digit to exchange code and remaining to number\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p11\"\u003EProgram to input a number and find whether it is even or odd\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p12\"\u003EProgram to find biggest of four no by using ternary operator\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p13\"\u003EProgram to print smallest of four no by using ternary operators\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p14\"\u003EProgram to accept a year and check the given year is leap or not by using ternary operator\u003C\/a\u003E\u0026nbsp;\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals2.html#p15\"\u003EProgram to find area of a triangle when there sides are given\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ol\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#controlstructures\" name=\"controlstructures\"\u003E\u003Cspan style=\"color: yellow; font-weight: normal;\"\u003ECONTROL STRUCTURES\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\"\u003EBack to contents\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv\u003E\n\u003Col style=\"text-align: left;\"\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p1\"\u003EProgram to multiply 2 number without using * operator\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p2\"\u003EProgram to determine Armstrong number\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p3\"\u003EProgram to input time in seconds and convert them into hours and seconds and display it\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p4\"\u003EProgram to determine Palindrome number\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures.html#p5\"\u003EProgram showing the use of 'goto' statement\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p6\"\u003EProgram for finding the factorial of a number\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p7\"\u003EProgram to find whether the entered character is vowel or not using if else\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p8\"\u003EProgram to find whether the entered character is vowel or not using switch case\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p9\"\u003EProgram to print the table of a given number till the user wishes\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures1.html#p10\"\u003EProgram to sum up all the integer numbers input at run time until zero is entered\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.htm#p11\"\u003EProgram to find whether a given number is Prime or Not\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.html#p12\"\u003EProgram to print ( list ) all the prime number between 1 to n\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.htm#p13\"\u003EProgram to print (list) Palindrome number from 10 to n\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.htm#p14\"\u003EProgram to print (list) Armstrong Number between two given numbers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures2.htm#p15\"\u003EProgram to print the factor of a given number\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#16\"\u003EProgram to print the fibonacii series till which user wishes\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#17\"\u003EProgram to determine whether entered character is capital case letter, small case letter, a digit or a special symbol\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#18\"\u003EProgram to find whether a number is Perfect Square or Not\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#19\"\u003EProgram to print (list) Perfect Square Number between any two number\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures3.html#20\"\u003EProgram for Bank account Handling\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html#p21\"\u003EProgram to award Grades\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html#p22\"\u003EGrade Program without using if-else statement\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html#p23\"\u003EProgram to calculate the sum of individual digits of a number\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-control-structures4.html#p24\"\u003EProgram to determine whether a given year is leap year or not\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-encode-and-decode-cipher.html\"\u003EProgram to encode and decode ( cipher )\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ol\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#patterns\" name=\"patterns\"\u003E\u003Cspan style=\"color: yellow; font-weight: normal;\"\u003EPATTERNS\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\"\u003EBack to contents\u003C\/a\u003E\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Col style=\"text-align: left;\"\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p1\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E*\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* *\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * *\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * *\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * * *\u0026nbsp;\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p2\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E* \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * * \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * * * \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * * * * ..... till n rows\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p3\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E1\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3 4\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3 4 5 .... till n rows\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p4\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E1\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E2 2\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E3 3 3\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E4 4 4 4\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 5 5 5 5 .... till n rows\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns.html#p5\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 1 1 1 1\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E2 2 2 2 2\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E3 3 3 3 3\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E4 4 4 4 4\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 5 5 5 5\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p6\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E5\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4 3\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4 3 2\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4 3 2 1\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p7\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3 4 5\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3 4\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p8\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4 3 2 1\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4 3 2\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4 3\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 4\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p9\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E        *\n      * *\n    * * *\n  * * * *\n* * * * *\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns1.html#p10\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E        1\n      1 2\n    1 2 3\n  1 2 3 4\n1 2 3 4 5\u003C\/span\u003E\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p11\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E        5\n      4 5\n    3 4 5\n  2 3 4 5\n1 2 3 4 5\n\u003C\/span\u003E\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p12\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E1\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* *\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * *\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3 4 5 .... till n rows\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p13\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E1                 1\n1 2             1 2\n1 2 3         1 2 3\n1 2 3 4     1 2 3 4\n1 2 3 4 5 1 2 3 4 5\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p14\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E1                 1\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2             2 1\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3         3 2 1\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3 4     4 3 2 1\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3 4 5 5 4 3 2 1\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-pointers2.html#p15\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E1                 5\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2             5 4\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3         5 4 3\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3 4     5 4 3 2\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E1 2 3 4 5 5 4 3 2 1\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#16\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E1  \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E2 6 \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E3 7 10\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E4 8 11 13\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E5 9 12 14 15 ... till n rows\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#17\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E******** ********\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E*******   *******\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E******     ****** \u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E*****       *****\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E****         ****\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E***           ***\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E**             **\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E*               *\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E\u003C\/span\u003E \n\u003Cspan style=\"color: blue;\"\u003E*               *\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E**             **\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E***           ***\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E****         ****\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E*****       ***** \u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E******     ******\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E*******   *******\u003C\/span\u003E\n\u003Cspan style=\"color: blue;\"\u003E******** ********\u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003Cbr \/\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#18\"\u003EProgram to print the given pattern\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E \n      *\n     ***\n    *****\n   *******\n  *********\n   *******  \n    *****\n     ***\n      * \u003C\/span\u003E\n\u003C\/pre\u003E\n\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#19\"\u003EProgram to print the given pattern :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E8 4 2 1\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E4 2 1\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E2 1\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E1\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/02\/c-programs-patterns3.html#20\"\u003EProgram to print Pascal triangle :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003C\/li\u003E\n\u003C\/ol\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#functions\" name=\"functions\" style=\"font-weight: normal;\"\u003E\u003Cspan style=\"color: yellow;\"\u003EFUNCTIONS\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\"\u003EBack to contents\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv\u003E\n\u003Col style=\"text-align: left;\"\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p1\"\u003EProgram to find sum of two numbers using function sum(int,int) that returns sum value\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p2\"\u003EProgram to print the area of a rectangle\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p3\"\u003EProgram to find the factorial of two numbers and add them and print the result\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p4\"\u003EProgram to implement functions that returns HCF OR GCD and LCM of two numbers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Cdiv style=\"text-align: justify;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p5\"\u003EImplement a function that takes two values of integer type and interchange them\u003C\/a\u003E\u003C\/div\u003E\n\u003Cdiv style=\"text-align: justify;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p5\"\u003E1. without using Third variable. You may use arithmetic operators\u003C\/a\u003E\u003C\/div\u003E\n\u003Cdiv style=\"text-align: justify;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-functions.html#p5\"\u003E2. With the use of third variable. You should not use arithmetic operator\u003C\/a\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p6\"\u003EWrite a function that receives a positive integer as input and returns the leading digit in its decimal representation\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p7\"\u003EImplement a function that receives an integer value and returns the number of prime factors of that number. If the number is itself a prime number then return 0\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p8\"\u003EProgram to find maximum number between three numbers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-function1.html#p9\"\u003EProgram to accept a number and print the sum of given and Reverse number using function\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ol\u003E\n\u003Cdiv\u003E\n\u003C\/div\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#recursion\" name=\"recursion\"\u003E\u003Cspan style=\"color: yellow; font-weight: normal;\"\u003ERECURSION\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\"\u003EBack to contents\u003C\/a\u003E\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Col style=\"text-align: left;\"\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p1\"\u003EProgram to find the factorial of a Number using recursion\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p2\"\u003EProgram to print sum of n natural numbers from 1 to n ( Number ) using recursion\u0026nbsp;\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p3\"\u003EProgram to calculate the power using recursion. Example a^b ( Here ^ = Power sign )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p4\"\u003EProgram to find the GCD ( Greatest Common Divisior ) or HCD ( Highes Common Factor ) using recursion\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion.html#p5\"\u003EProgram to Reverse a Number using recursion\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p6\"\u003EProgram to find whether a number is Palindrome or not using recursion\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p7\"\u003EProgram to find whether a number is Armstrong or not using recursion\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p8\"\u003EProgram to print the fibonacci series upto nth terms using recursion\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p9\"\u003EProgram to print first \"n\" natural numbers in reverse order\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p10\"\u003EProgram to print patter :\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E*\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* *\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * *\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * * *\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003Cli\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-recursion1.html#p11\"\u003EProgram to print given pattern : \u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\n\u003Cspan style=\"color: blue;\"\u003E*\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* *\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * \u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * *\u003C\/span\u003E\u003Cbr \/\u003E\n\u003Cspan style=\"color: blue;\"\u003E* * * * * till n terms\u003C\/span\u003E\u003C\/div\u003E\n\u003C\/li\u003E\n\u003C\/ol\u003E\n\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#arrays\" name=\"arrays\" style=\"font-weight: normal;\"\u003E\u003Cspan style=\"color: yellow;\"\u003EARRAYS\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\"\u003EBack to contents\u003C\/a\u003E\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Col style=\"text-align: left;\"\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p1\"\u003EProgram to accept elements in an array and display it\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p2\"\u003EProgram to accept elements in an array and display sum of all the elements\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p3\"\u003EProgram to insert element in between an array. ( INSERTION )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p4\"\u003EProgram to delete element from an array. ( DELETION )\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays.html#p5\"\u003EProgram to perform Transpose of a Matrix\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p6\"\u003EProgram to find Minimum element in an array\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p7\"\u003EProgram to find highest minimum temperature and lowest maximum temperature\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p8\"\u003EProgram to accept 10 numbers and print first five numbers in original order and print last five numbers in reverse order\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p9\"\u003EProgram showing Passing array to function.\u0026nbsp;Program finds the average of 5 marks input by user\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays1.html#p10\"\u003EProgram to initialize a character array and display the initialized character array in reverse order\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p11\"\u003EProgram to generate histogram of entered number\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p12\"\u003EProgram to enter values into a two-dimensional integer array of size (4 X 3) and then display it in matrix form\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p13\"\u003EWrite a 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\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p14\"\u003EProgram 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\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays2.html#p15\"\u003EProgram 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\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays3.html#p16\"\u003EPrograms to multiply two Matrices\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays3.html#p17\"\u003EProgram to print a diagonal matrix with diagonal value enter by user\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays3.html#p18\"\u003EProgram to print a anti diagonal matrix with diagonal value enter by user\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-arrays3.html#p19\"\u003EProgram to print the sum of diagonal values and anti-diagonal values of a matrix\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ol\u003E\n\u003Cdiv\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#strings\" name=\"strings\" style=\"font-weight: normal;\"\u003E\u003Cspan style=\"color: yellow;\"\u003ESTRINGS\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\"\u003EBack to contents\u003C\/a\u003E\u003C\/div\u003E\n\u003Cdiv\u003E\n\u003Col style=\"text-align: left;\"\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p1\"\u003EProgram to accept a string and print it\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p2\"\u003EProgram to accept a character in the uppercase and print in lower case\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p3\"\u003EProgram to accept a string in Lower case and print it in upper case\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p4\"\u003EProgram to accept a character in any case and print in another case\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings.html#p5\"\u003EProgram to accept a string and print it by using while loop\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p6\"\u003EProgram to find length of a string using string function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p7\"\u003EProgram to find length of a string without using string function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p8\"\u003EProgram for Copy a String to another using String Function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings1.html#p9\"\u003EProgram to find length of a string without using string function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#p10\"\u003EProgram for Compare two String using String Function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#p11\"\u003EProgram for Compare two String without using String Function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#p12\"\u003EProgram for String Reverse with String Function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#p13\"\u003EProgram for String Reverse without String Function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#p14\"\u003EProgram for String Concatenation with String Function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strigns2.html#p15\"\u003EProgram for String Concatenation without String Function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#p16\"\u003EProgram to convert all characters in a string to lower case using string function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#p17\"\u003EProgram to convert all characters in a string to lower case without using string function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#p18\"\u003EProgram to convert all characters in a string to upper case using string function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#p19\"\u003EProgram to convert all characters in a string to upper case without using string function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings3.html#p20\"\u003EProgram to enter 5 string and print them with their length\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#p21\"\u003EProgram to accept a string and print each word of the string separately also print total number of words\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#p22\"\u003EProgram to accept a string and display vowels frequency( total number of vowels)\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#p23\"\u003EProgram to accept a string and display frequency of each vowel along with vowel\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#p24\"\u003EProgram to enter a word and check whether it is palindrome or not using string function\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-strings4.html#p25\"\u003EProgram to enter a word and check whether it is palindrome or not without using string function\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ol\u003E\n\u003Cdiv style=\"text-align: justify;\"\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#pointers\" name=\"pointers\"\u003E\u003Cspan style=\"color: yellow; font-weight: normal;\"\u003EPOINTERS\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\"\u003EBack to contents\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv\u003E\n\u003Col style=\"text-align: left;\"\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p1\"\u003EProgram to accept two numbers and print its address along with the numbers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p2\"\u003EProgram to accept two numbers and print the sum of given two numbers by using pointers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p3\"\u003EProgram to interchange two values using pointers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p4\"\u003EImplement a function interchange() to interchange two values using pointers\u0026nbsp;\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers.html#p5\"\u003EProgram to sum all the elements of an array using pointer\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p6\"\u003EProgram to find maximum element of an array of elements using pointer\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p7\"\u003EProgram to print sum of all the elements in 2D array using pointer\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u0026nbsp;\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p8\"\u003EProgram to sort an array of elements using pointers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p9\"\u003EProgram to sort string using pointers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p10\"\u003EProgram to search given element in an array using pointers\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-pointers1.html#p11\"\u003EProgram to demonstrate the use of pointer to pointer\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ol\u003E\n\u003Cdiv\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003Ch2 style=\"text-align: left;\"\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#dms\" name=\"dms\" style=\"font-weight: normal;\"\u003E\u003Cspan style=\"color: yellow;\"\u003EDYNAMIC MEMORY ALLOCATION\u003C\/span\u003E\u003C\/a\u003E\u003C\/h2\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#contents\"\u003EBack to contents\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv\u003E\n\u003Col style=\"text-align: left;\"\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html#p1\"\u003EProgram to dynamically allocate memory using calloc for \"n\" integer elements, input elements, display it and then free the memory\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html#p2\"\u003EProgram to dynamically allocate memory using malloc for \"n\" integer elements, input elements, display it and then free the memory\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html#p3\"\u003EProgram to dynamically allocate memory using malloc for \"n\" integer elements, input elements and then display it. Then reallocate memory for the same pointer variable, input elements, display it and then free the memory\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma.html#p4\"\u003EProgram to find the length of the string\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html#p5\"\u003EProgram to find the sum of \"n\" elements\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html#p6\"\u003EProgram to sort \"n\" elements in ascending order\u0026nbsp;\u003C\/a\u003E\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html#p7\"\u003EProgram to search an element\u003C\/a\u003E\u0026nbsp;\u003C\/li\u003E\n\u003Cli style=\"text-align: justify;\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-dma1.html#p8\"\u003EProgram to enter three strings and sort them in ascending order alphabetically\u003C\/a\u003E\u003C\/li\u003E\n\u003C\/ol\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n\u003C\/div\u003E\n"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/9059165963397579917\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/9059165963397579917"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/9059165963397579917"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs.html","title":"C PROGRAMS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}},{"id":{"$t":"tag:blogger.com,1999:blog-8285804830535272268.post-2154845741511983930"},"published":{"$t":"2014-01-28T06:25:00.000-08:00"},"updated":{"$t":"2014-04-16T01:09:09.696-07:00"},"category":[{"scheme":"http://www.blogger.com/atom/ns#","term":"C Programs"},{"scheme":"http://www.blogger.com/atom/ns#","term":"Fundamental"}],"title":{"type":"text","$t":"C PROGRAMS : FUNDAMENTALS"},"content":{"type":"html","$t":"\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ctitle\u003EC PROGRAMS : FUNDAMENTALS\u003C\/title\u003E\u003Cbr \/\u003E\n\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Cdiv dir=\"ltr\" style=\"text-align: left;\" trbidi=\"on\"\u003E\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p1\" name=\"p1\"\u003E1. A simple program for printing a line of text\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \/\/ Linux user - Remove this\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n printf(\"Hello this is my first C program\");\n getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p2\" name=\"p2\"\u003E2. Program to input integer number and display it\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n    \/\/ variable to take input\n    int n;\n    \n    printf(\"Enter any number \");\n    scanf(\"%d\",\u0026amp;n);\n    printf(\"Input number=%d\",n);\u003C\/span\u003E\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cstdio .h=\"\"\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E   \u0026nbsp;\u003C\/span\u003E\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003Cpre\u003E\u003Cstdio .h=\"\"\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E    \/\/ holds the output screen defined in header file conio.h\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n    \n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p3\" name=\"p3\"\u003E3. Program to add, subtract, multiply and divide two numbers\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n    int a, b;\n    \n    printf(\"Enter any two number \");\n    scanf(\"%d\",\u0026amp;a);\n    scanf(\"%d\",\u0026amp;b);\n    printf(\"Sum=%d\",a+b);\n    printf(\"\\nSubtracted value=%d\",a-b);\n    printf(\"\\nMultiplied value=%d\",a*b);\n    printf(\"\\n Division value=%d\",a\/b);\n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n    return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p4\" name=\"p4\"\u003E4. Program to subtract two numbers without using arithmetic operators ( - )\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n    int a, b, r;\n    \n    printf(\"Enter any two number \");\n    scanf(\"%d\",\u0026amp;a);\n    scanf(\"%d\",\u0026amp;b);\n    r=a+(~b)+1;\n    printf(\"Subtracted value=%d\", r);\n    getch(); \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E    return 0;\n}\u003C\/span\u003E\n\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003Cbr \/\u003E\n\u003C\/div\u003E\u003Cbr \/\u003E\n\u003Ca href=\"http:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#p5\" name=\"p5\"\u003E5. Program to find the greatest between 3 integers( numbers ) using ternary or conditional operator\u003C\/a\u003E\u003Cbr \/\u003E\n\u003Cdiv class=\"mokcode\"\u003E\u003Cpre\u003E\u003Cspan style=\"color: blue;\"\u003E#include\u0026lt;stdio.h\u0026gt;\u003C\/span\u003E\u003Cstdio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\n#include\u0026lt;conio.h\u0026gt; \u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cconio .h=\"\"\u003E\u003Cspan style=\"color: blue;\"\u003E\nint main()\n{\n \/\/ Variable for 3 integers and for storing greatest integer\n int a, b, c, g;\n \n \/\/ Inputting integers\n printf(\"Enter three integers:\");\n scanf(\"%d %d %d\",\u0026amp;a,\u0026amp;b,\u0026amp;c);\n \n \/\/ Determining the greatest integer using ternary or conditional operator\n g=(a\u0026gt;b \u0026amp;\u0026amp; b\u0026gt;c) ? a : (b\u0026gt;c \u0026amp;\u0026amp; b\u0026gt;a) ? b : (c\u0026gt;a \u0026amp;\u0026amp; c\u0026gt;b) ? c : 0;\n \n \/\/ displaying greatest value\n if(g!=0)\n printf(\"Greagest integer: %d\",g);\n else\n printf(\"None is greatest: Two integers have same value\" );\n \n getch();\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\/\/ Linux user - Remove this\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n\u003C\/span\u003E\u003Cspan style=\"color: blue;\"\u003E\n return 0;\n}\u003C\/span\u003E\u003C\/conio\u003E\u003C\/stdio\u003E\u003C\/pre\u003E\u003C\/div\u003E\u003C\/div\u003E"},"link":[{"rel":"replies","type":"application/atom+xml","href":"https:\/\/www.comp-psyche.com\/feeds\/2154845741511983930\/comments\/default","title":"Post Comments"},{"rel":"replies","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html#comment-form","title":"0 Comments"},{"rel":"edit","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/2154845741511983930"},{"rel":"self","type":"application/atom+xml","href":"https:\/\/www.blogger.com\/feeds\/8285804830535272268\/posts\/default\/2154845741511983930"},{"rel":"alternate","type":"text/html","href":"https:\/\/www.comp-psyche.com\/2014\/01\/c-programs-fundamentals.html","title":"C PROGRAMS : FUNDAMENTALS"}],"author":[{"name":{"$t":"Mantu Kumar"},"uri":{"$t":"http:\/\/www.blogger.com\/profile\/02897308282659594376"},"email":{"$t":"noreply@blogger.com"},"gd$image":{"rel":"http://schemas.google.com/g/2005#thumbnail","width":"16","height":"16","src":"https:\/\/img1.blogblog.com\/img\/b16-rounded.gif"}}],"thr$total":{"$t":"0"}}]}});