<br />
<b>Warning</b>:  Undefined array key "global_protection_id" in <b>/home/wikitechy/public_html/interview-questions/wp-content/plugins/content-protector/inc/class-ps-rest-handler.php</b> on line <b>51</b><br />
{"id":406,"date":"2021-07-13T00:20:02","date_gmt":"2021-07-13T00:20:02","guid":{"rendered":"https:\/\/www.wikitechy.com\/interview-questions\/?p=406"},"modified":"2021-09-18T06:51:04","modified_gmt":"2021-09-18T06:51:04","slug":"print-pyramid-triangle-in-cpp","status":"publish","type":"post","link":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/","title":{"rendered":"Print pyramid triangle in C++"},"content":{"rendered":"<div class=\"TextHeading\">\n<div class=\"hddn\">\n<h2 id=\"print-pyramid-triangle-in-c\" class=\"color-pink\" style=\"text-align: justify;\">Print pyramid triangle in C++<\/h2>\n<\/div>\n<\/div>\n<div class=\"Content\" style=\"text-align: justify;\">\n<div class=\"hddn\">\n<ul>\n<li>To print pyramid\u00a0<a href=\"https:\/\/www.wikitechy.com\/tutorials\/csharp\/csharp-fibonacci-series\" target=\"_blank\" rel=\"noopener\">triangle<\/a>\u00a0in C++, we have use two for loop, the outer for loop and the inner for loop.<\/li>\n<li>The outer for loop is responsible for rows and the inner for loop is responsible for column.<\/li>\n<li>C++ programs to print different types of\u00a0<a href=\"https:\/\/www.wikitechy.com\/technology\/c-program-to-print-patterns-of-numbers-and-stars\/\" target=\"_blank\" rel=\"noopener\">patterns using stars(*)<\/a>, numbers, and characters or alphabets.<\/li>\n<li>This C++ program prints the full pyramid using stars(*).<\/li>\n<\/ul>\n<h2 id=\"sample-code-in-c\" class=\"color-purple\">Sample Code in C++<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-cpp code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-cpp code-embed-code\">#include &lt;iostream&gt;<br\/>using namespace std;<br\/>   int main()<br\/>{<br\/>    int j, rows;<br\/>       cout &lt;&lt;&quot;Enter number of rows: &quot;;<br\/>    cin &gt;&gt; rows;<br\/>       for(int i = 1, k = 0; i &lt;= rows; ++i, k = 0)<br\/>    {<br\/>        for(j = 1; j &lt;= rows-i; ++j)<br\/>        {<br\/>            cout &lt;&lt;&quot;  &quot;;<br\/>        }<br\/>        while(k != 2*i-1)<br\/>        {<br\/>            cout &lt;&lt; &quot;* &quot;;<br\/>            ++k;<br\/>        }<br\/>        cout &lt;&lt; endl;<br\/>    }    <br\/>    return 0;<br\/>}<\/code><\/pre> <\/div>\n<h2 id=\"output\" class=\"color-purple\">Output<\/h2>\n<div class=\"code-embed-wrapper\"> <div class=\"code-embed-infos\"> <\/div> <pre class=\"language-cpp code-embed-pre line-numbers\"  data-start=\"1\" data-line-offset=\"0\"><code class=\"language-cpp code-embed-code\">Enter number of rows : 7   <br\/>            * <br\/>          * * * <br\/>        * * * * * <br\/>      * * * * * * * <br\/>    * * * * * * * * * <br\/>  * * * * * * * * * * * <br\/>* * * * * * * * * * * * * <\/code><\/pre> <\/div>\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Answer : To print pyramid triangle in C++, we have use two for loop&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"passster_activate_protection":false,"passster_protect_child_pages":"","passster_protection_type":"password","passster_password":"","passster_activate_overwrite_defaults":"","passster_headline":"","passster_instruction":"","passster_placeholder":"","passster_button":"","passster_id":"","passster_activate_misc_settings":"","passster_redirect_url":"","passster_hide":"no","passster_area_shortcode":"","gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[2080],"tags":[195,491,2621,360,368,211,1902,2628,2639,2631,2622,2641,2638,2637,2623,199,198,363,1903,205,1883,2630,2632,2117,220,222,2122,212,2120,2625,2121,710,207,2640,366,204,2627,2618,2617,1911,1906,1907,1912,217,2116,2634,2624,1905,1910,2633,1913,2629,2635,2626,2620,2123,1909,1914,210,200,2118,1885,2636,2619,968,216,2119],"class_list":["post-406","post","type-post","status-publish","format-standard","hentry","category-cpp","tag-accenture-interview-questions-and-answers","tag-applied-materials-interview-questions-and-answers","tag-area-of-a-triangular-pyramid","tag-atos-interview-questions-and-answers","tag-bmc-software-interview-questions-and-answers","tag-bosch-india-software-interview-questions-and-answers","tag-c-program-to-print-patterns-of-numbers","tag-c-program-to-print-patterns-of-numbers-and-alphabets","tag-c-program-to-print-patterns-of-numbers-and-stars-in-a-pyramid-shape","tag-c-program-to-print-pyramid-of-numbers-in-reverse-order","tag-c-program-to-print-pyramid-pattern-of-numbers","tag-c-pattern-programs","tag-c-program-to-print-diamond-of-stars","tag-c-program-to-print-pyramid-of-numbers","tag-c-program-to-print-pyramid-using","tag-casting-networks-india-pvt-limited-interview-questions-and-answers","tag-chetu-interview-questions-and-answers","tag-ciena-corporation-interview-questions-and-answers","tag-cstar-programme","tag-dell-international-services-india-pvt-ltd-interview-questions-and-answers","tag-diamond-pattern-programs-in-c","tag-difficult-number-pattern-programs-in-c","tag-double-pyramid-pattern-in-c","tag-einfochips-interview-questions-and-answers","tag-electronics-arts-inc-interview-questions-and-answers","tag-flipkart-interview-questions-and-answers","tag-harman-international-interview-questions-and-answers","tag-indecomm-global-services-interview-questions-and-answers","tag-larsen-toubro-interview-questions-and-answers","tag-letter-pyramid-c","tag-mathworks-india-private-limited-interview-questions-and-answers","tag-mavenir-interview-questions-and-answers","tag-mphasis-interview-questions-and-answers","tag-nested-loop-c-shapes","tag-netapp-interview-questions-and-answers","tag-oracle-corporation-interview-questions-and-answers","tag-pascal-triangle-in-c-using-array","tag-pascals-triangle-formula","tag-pascals-triangle-patterns","tag-pattern-code","tag-pattern-programs-in-c","tag-pattern-programs-in-java","tag-patterns-in-c","tag-peoplestrong-interview-questions-and-answers","tag-philips-software-centre-pvt-ltd-interview-questions-and-answers","tag-print-and-pattern","tag-print-pascal-triangle-c","tag-print-pattern","tag-programming-patterns","tag-pyramid-of-numbers","tag-pyramid-program-in-c","tag-pyramid-program-in-c-with-explanation","tag-pyramid-shape","tag-right-triangle-c","tag-square-based-pyramid","tag-srm-technologies-interview-questions-and-answers","tag-star-pattern","tag-star-pattern-in-c","tag-symphony-teleca-interview-questions-and-answers","tag-tech-mahindra-interview-questions-and-answers","tag-tecnotree-interview-questions-and-answers","tag-toughest-pattern-programs-in-c","tag-triangular-pyramid","tag-volume-of-a-square-based-pyramid","tag-wipro-infotech-interview-questions-and-answers","tag-wipro-interview-questions-and-answers","tag-yash-technologies-interview-questions-and-answers"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v22.6 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Print pyramid triangle in C++ - C++ Interview Questions - Wikitechy<\/title>\n<meta name=\"description\" content=\"Print pyramid triangle in C++ - To print pyramid triangle in C++, we have use two for loop, the outer for loop and the inner for loop.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Print pyramid triangle in C++ - C++ Interview Questions - Wikitechy\" \/>\n<meta property=\"og:description\" content=\"Print pyramid triangle in C++ - To print pyramid triangle in C++, we have use two for loop, the outer for loop and the inner for loop.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/\" \/>\n<meta property=\"og:site_name\" content=\"Wikitechy\" \/>\n<meta property=\"article:published_time\" content=\"2021-07-13T00:20:02+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-18T06:51:04+00:00\" \/>\n<meta name=\"author\" content=\"Editor\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Editor\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"1 minute\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/\",\"name\":\"Print pyramid triangle in C++ - C++ Interview Questions - Wikitechy\",\"isPartOf\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\"},\"datePublished\":\"2021-07-13T00:20:02+00:00\",\"dateModified\":\"2021-09-18T06:51:04+00:00\",\"author\":{\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\"},\"description\":\"Print pyramid triangle in C++ - To print pyramid triangle in C++, we have use two for loop, the outer for loop and the inner for loop.\",\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/\"]}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#website\",\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/\",\"name\":\"Wikitechy\",\"description\":\"Interview Questions\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757\",\"name\":\"Editor\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g\",\"caption\":\"Editor\"},\"url\":\"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Print pyramid triangle in C++ - C++ Interview Questions - Wikitechy","description":"Print pyramid triangle in C++ - To print pyramid triangle in C++, we have use two for loop, the outer for loop and the inner for loop.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/","og_locale":"en_US","og_type":"article","og_title":"Print pyramid triangle in C++ - C++ Interview Questions - Wikitechy","og_description":"Print pyramid triangle in C++ - To print pyramid triangle in C++, we have use two for loop, the outer for loop and the inner for loop.","og_url":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/","og_site_name":"Wikitechy","article_published_time":"2021-07-13T00:20:02+00:00","article_modified_time":"2021-09-18T06:51:04+00:00","author":"Editor","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Editor","Est. reading time":"1 minute"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/","url":"https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/","name":"Print pyramid triangle in C++ - C++ Interview Questions - Wikitechy","isPartOf":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website"},"datePublished":"2021-07-13T00:20:02+00:00","dateModified":"2021-09-18T06:51:04+00:00","author":{"@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757"},"description":"Print pyramid triangle in C++ - To print pyramid triangle in C++, we have use two for loop, the outer for loop and the inner for loop.","inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wikitechy.com\/interview-questions\/cpp\/print-pyramid-triangle-in-cpp\/"]}]},{"@type":"WebSite","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#website","url":"https:\/\/www.wikitechy.com\/interview-questions\/","name":"Wikitechy","description":"Interview Questions","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wikitechy.com\/interview-questions\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"en-US"},{"@type":"Person","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/4d5a581fb5470d1560324bddc5e8b757","name":"Editor","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.wikitechy.com\/interview-questions\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e9531079fe7e07841b7b156c04d65e5f39d4adfd18b6ffe3edfff8ca5aab85b5?s=96&d=mm&r=g","caption":"Editor"},"url":"https:\/\/www.wikitechy.com\/interview-questions\/author\/editor\/"}]}},"_links":{"self":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/406","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/comments?post=406"}],"version-history":[{"count":2,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/406\/revisions"}],"predecessor-version":[{"id":3587,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/posts\/406\/revisions\/3587"}],"wp:attachment":[{"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/media?parent=406"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/categories?post=406"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wikitechy.com\/interview-questions\/wp-json\/wp\/v2\/tags?post=406"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}