{"id":57,"date":"2026-05-19T14:45:51","date_gmt":"2026-05-19T14:45:51","guid":{"rendered":"https:\/\/gigz.pk\/cpp\/?post_type=lesson&#038;p=57"},"modified":"2026-05-22T06:11:34","modified_gmt":"2026-05-22T06:11:34","slug":"writing-first-program","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/cpp\/?lesson=writing-first-program","title":{"rendered":"Writing First Program"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Writing your first C++ program is the first step toward learning programming. A simple program helps you understand the basic structure of C++ and how code is executed.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Basic Structure of a C++ Program<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">A C++ program usually contains:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Header files<\/li>\n\n\n\n<li>Main function<\/li>\n\n\n\n<li>Statements<\/li>\n\n\n\n<li>Output commands<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">First C++ Program<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;<br>using namespace std;<br><br>int main() {<br>    cout &lt;&lt; \"Hello, World!\";<br>    return 0;<br>}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding the Program<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">#include &lt;iostream&gt;<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This line includes the input and output library in the program.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">It allows you to use:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>cout<\/li>\n\n\n\n<li>cin<\/li>\n\n\n\n<li>endl<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">using namespace std;<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This statement allows you to use standard C++ features without writing <code>std::<\/code> repeatedly.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>using namespace std;<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">main() Function<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The <code>main()<\/code> function is the starting point of every C++ program.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int main() {<br>}<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Program execution begins from here.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">cout Statement<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\"><code>cout<\/code> is used to display output on the screen.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cout &lt;&lt; \"Hello, World!\";<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">return 0;<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">This statement ends the program successfully.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>return 0;<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Output of Program<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello, World!<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Steps to Run the Program<\/h2>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open your IDE or code editor<\/li>\n\n\n\n<li>Create a new C++ file<\/li>\n\n\n\n<li>Write the code<\/li>\n\n\n\n<li>Save the file with <code>.cpp<\/code> extension<\/li>\n\n\n\n<li>Compile the program<\/li>\n\n\n\n<li>Run the program<\/li>\n<\/ol>\n\n\n\n<h2 class=\"wp-block-heading\">Important Points<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Every C++ program must have a <code>main()<\/code> function<\/li>\n\n\n\n<li>Statements usually end with semicolon <code>;<\/code><\/li>\n\n\n\n<li>C++ is case-sensitive<\/li>\n\n\n\n<li>Curly braces <code>{}<\/code> define blocks of code<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Why Your First Program is Important<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Your first program helps you:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Understand program structure<\/li>\n\n\n\n<li>Learn compilation and execution<\/li>\n\n\n\n<li>Practice syntax basics<\/li>\n\n\n\n<li>Build confidence in coding<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Writing the first C++ program is the beginning of your programming journey. The \u201cHello, World!\u201d program introduces the basic structure of C++ and helps you understand how programs are written, compiled, and executed.<\/p>\n\n\n<div class=\"yoast-breadcrumbs\"><span><span><a href=\"https:\/\/gigz.pk\/cpp\">Home<\/a><\/span> \u00bb <span class=\"breadcrumb_last\" aria-current=\"page\">C++ Fundamentals (Beginner Level) > Introduction to C++ > Writing First Program<\/span><\/span><\/div>\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><\/div>\n","protected":false},"menu_order":5,"template":"","class_list":["post-57","lesson","type-lesson","status-publish","hentry"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Writing First Program - Learn C++Language with GiGz.PK<\/title>\n<meta name=\"description\" content=\"Learn how to write and run your first C++ program with basic syntax, structure, output, and compilation steps.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Writing First Program - Learn C++Language with GiGz.PK\" \/>\n<meta property=\"og:description\" content=\"Learn how to write and run your first C++ program with basic syntax, structure, output, and compilation steps.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/gigz.pk\/\" \/>\n<meta property=\"og:site_name\" content=\"Learn C++Language with GiGz.PK\" \/>\n<meta property=\"article:modified_time\" content=\"2026-05-22T06:11:34+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\\\/\\\/gigz.pk\\\/cpp\\\/?lesson=writing-first-program\",\"url\":\"https:\\\/\\\/gigz.pk\\\/\",\"name\":\"Writing First Program - Learn C++Language with GiGz.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/cpp\\\/#website\"},\"datePublished\":\"2026-05-19T14:45:51+00:00\",\"dateModified\":\"2026-05-22T06:11:34+00:00\",\"description\":\"Learn how to write and run your first C++ program with basic syntax, structure, output, and compilation steps.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/gigz.pk\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/gigz.pk\\\/cpp\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"C++ Fundamentals (Beginner Level) > Introduction to C++ > Writing First Program\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/gigz.pk\\\/cpp\\\/#website\",\"url\":\"https:\\\/\\\/gigz.pk\\\/cpp\\\/\",\"name\":\"Learn C++Language with GiGz.PK\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/gigz.pk\\\/cpp\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Writing First Program - Learn C++Language with GiGz.PK","description":"Learn how to write and run your first C++ program with basic syntax, structure, output, and compilation steps.","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:\/\/gigz.pk\/","og_locale":"en_US","og_type":"article","og_title":"Writing First Program - Learn C++Language with GiGz.PK","og_description":"Learn how to write and run your first C++ program with basic syntax, structure, output, and compilation steps.","og_url":"https:\/\/gigz.pk\/","og_site_name":"Learn C++Language with GiGz.PK","article_modified_time":"2026-05-22T06:11:34+00:00","twitter_card":"summary_large_image","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":["WebPage","FAQPage"],"@id":"https:\/\/gigz.pk\/cpp\/?lesson=writing-first-program","url":"https:\/\/gigz.pk\/","name":"Writing First Program - Learn C++Language with GiGz.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/cpp\/#website"},"datePublished":"2026-05-19T14:45:51+00:00","dateModified":"2026-05-22T06:11:34+00:00","description":"Learn how to write and run your first C++ program with basic syntax, structure, output, and compilation steps.","breadcrumb":{"@id":"https:\/\/gigz.pk\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/gigz.pk\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/gigz.pk\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/gigz.pk\/cpp"},{"@type":"ListItem","position":2,"name":"C++ Fundamentals (Beginner Level) > Introduction to C++ > Writing First Program"}]},{"@type":"WebSite","@id":"https:\/\/gigz.pk\/cpp\/#website","url":"https:\/\/gigz.pk\/cpp\/","name":"Learn C++Language with GiGz.PK","description":"","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/gigz.pk\/cpp\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/gigz.pk\/cpp\/index.php?rest_route=\/wp\/v2\/lesson\/57","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gigz.pk\/cpp\/index.php?rest_route=\/wp\/v2\/lesson"}],"about":[{"href":"https:\/\/gigz.pk\/cpp\/index.php?rest_route=\/wp\/v2\/types\/lesson"}],"wp:attachment":[{"href":"https:\/\/gigz.pk\/cpp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=57"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}