{"id":25197,"date":"2017-10-15T15:35:11","date_gmt":"2017-10-15T10:05:11","guid":{"rendered":"https:\/\/www.wikitechy.com\/technology\/?p=25197"},"modified":"2017-10-15T15:35:11","modified_gmt":"2017-10-15T10:05:11","slug":"c-program-to-print-diamond-pattern","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/technology\/c-program-to-print-diamond-pattern\/","title":{"rendered":"C program to print diamond pattern"},"content":{"rendered":"<p>Diamond pattern in c: This code\u00a0C program to print diamond <a href=\"https:\/\/www.wikitechy.com\/technology\/palindrome-numbers\/\">pattern\u00a0<\/a>of stars. Diamond shape is as follows:<\/p>\n<pre>  *\r\n ***\r\n*****\r\n ***\r\n  *\r\n<\/pre>\n<h2 id=\"ad-typebanner\">[ad type=\u201dbanner\u201d]<\/h2>\n<h2 id=\"c-programming-code\">C programming code<\/h2>\n[pastacode lang=\u201dc\u201d manual=\u201d%23include%20%3Cstdio.h%3E%0A%20%0Aint%20main()%0A%7B%0A%20%20int%20n%2C%20c%2C%20k%2C%20space%20%3D%201%3B%0A%20%0A%20%20printf(%22Enter%20number%20of%20rows%5Cn%22)%3B%0A%20%20scanf(%22%25d%22%2C%20%26n)%3B%0A%20%0A%20%20space%20%3D%20n%20-%201%3B%0A%20%0A%20%20for%20(k%20%3D%201%3B%20k%20%3C%3D%20n%3B%20k%2B%2B)%0A%20%20%7B%0A%20%20%20%20for%20(c%20%3D%201%3B%20c%20%3C%3D%20space%3B%20c%2B%2B)%0A%20%20%20%20%20%20printf(%22%20%22)%3B%0A%20%0A%20%20%20%20space\u2013%3B%0A%20%0A%20%20%20%20for%20(c%20%3D%201%3B%20c%20%3C%3D%202*k-1%3B%20c%2B%2B)%0A%20%20%20%20%20%20printf(%22*%22)%3B%0A%20%0A%20%20%20%20printf(%22%5Cn%22)%3B%0A%20%20%7D%0A%20%0A%20%20space%20%3D%201%3B%0A%20%0A%20%20for%20(k%20%3D%201%3B%20k%20%3C%3D%20n%20-%201%3B%20k%2B%2B)%0A%20%20%7B%0A%20%20%20%20for%20(c%20%3D%201%3B%20c%20%3C%3D%20space%3B%20c%2B%2B)%0A%20%20%20%20%20%20printf(%22%20%22)%3B%0A%20%0A%20%20%20%20space%2B%2B%3B%0A%20%0A%20%20%20%20for%20(c%20%3D%201%20%3B%20c%20%3C%3D%202*(n-k)-1%3B%20c%2B%2B)%0A%20%20%20%20%20%20printf(%22*%22)%3B%0A%20%0A%20%20%20%20printf(%22%5Cn%22)%3B%0A%20%20%7D%0A%20%0A%20%20return%200%3B%0A%7D\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n<p>Output of program:<\/p>\n<h2 id=\"c-program-to-print-diamond-using-recursion\">C program to print diamond using recursion<\/h2>\n[pastacode lang=\u201dc\u201d manual=\u201d%23include%20%3Cstdio.h%3E%0A%20%0Avoid%20print%20(int)%3B%0A%20%0Aint%20main%20()%20%7B%0A%20%20%20int%20rows%3B%0A%20%0A%20%20%20scanf(%22%25d%22%2C%20%26rows)%3B%0A%20%0A%20%20%20print(rows)%3B%0A%20%0A%20%20%20return%200%3B%0A%7D%0A%20%0Avoid%20print%20(int%20r)%20%7B%0A%20%20%20int%20c%2C%20space%3B%0A%20%20%20static%20int%20stars%20%3D%20-1%3B%0A%20%0A%20%20%20if%20(r%20%3C%3D%200)%0A%20%20%20%20%20return%3B%0A%20%0A%20%20%20space%20%3D%20r%20-%201%3B%0A%20%20%20stars%20%2B%3D%202%3B%0A%20%0A%20%20%20for%20(c%20%3D%200%3B%20c%20%3C%20space%3B%20c%2B%2B)%0A%20%20%20%20%20%20printf(%22%20%22)%3B%0A%20%0A%20%20%20for%20(c%20%3D%200%3B%20c%20%3C%20stars%3B%20c%2B%2B)%0A%20%20%20%20%20%20printf(%22*%22)%3B%20%0A%20%0A%20%20%20printf(%22%5Cn%22)%3B%0A%20%0A%20%20%20print(\u2013r)%3B%0A%20%0A%20%20%20space%20%3D%20r%20%2B%201%3B%20%0A%20%20%20stars%20-%3D%202%3B%0A%20%0A%20%20%20for%20(c%20%3D%200%3B%20c%20%3C%20space%3B%20c%2B%2B)%0A%20%20%20%20%20%20printf(%22%20%22)%3B%0A%20%0A%20%20%20for%20(c%20%3D%200%3B%20c%20%3C%20stars%3B%20c%2B%2B)%0A%20%20%20%20%20%20printf(%22*%22)%3B%0A%20%0A%20%20%20printf(%22%5Cn%22)%3B%0A%7D\u201d message=\u201d\u201d highlight=\u201d\u201d provider=\u201dmanual\u201d\/]\n[ad type=\u201dbanner\u201d]\n","protected":false},"excerpt":{"rendered":"<p>C program to print diamond pattern &#8211; C Programming &#8211; Diamond pattern in c: This code print diamond pattern of stars. Diamond shape is as follows<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[69866,1],"tags":[72088,72091,72085,72086,72083,72082,72084,72078,72060,72087,72076,72081,72062,72090,72079,72077,72094,72096,72092,72089,72095,72093,72080],"class_list":["post-25197","post","type-post","status-publish","format-standard","hentry","category-c-programming","category-coding","tag-c-code-for-diamond-pattern","tag-c-program-for-diamond-pattern","tag-c-program-to-print-diamond","tag-c-program-to-print-diamond-of-stars","tag-c-program-to-print-diamond-pattern","tag-c-program-to-print-diamond-pattern-of-alphabets","tag-c-program-to-print-diamond-pattern-of-numbers","tag-c-program-to-print-pattern-of-alphabets","tag-c-program-to-print-patterns-of-numbers-and-stars-in-a-pyramid-shape","tag-diamond-pattern","tag-diamond-pattern-in-c-using-while-loop","tag-diamond-pattern-in-c","tag-diamond-pattern-programs-in-c","tag-diamond-pattern-programs-in-java","tag-half-diamond-pattern-in-c","tag-hollow-diamond-pattern-in-c","tag-how-to-draw-diamond-pattern","tag-java-program-for-diamond-pattern","tag-java-program-to-print-diamond-pattern","tag-java-program-to-print-diamond-pattern-of-stars","tag-print-diamond-pattern-in-c","tag-print-diamond-pattern-in-java","tag-program-to-print-diamond-pattern-in-java"],"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/25197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/comments?post=25197"}],"version-history":[{"count":0,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/posts\/25197\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/media?parent=25197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/categories?post=25197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/technology\/wp-json\/wp\/v2\/tags?post=25197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}