{"id":89,"date":"2026-05-20T11:18:37","date_gmt":"2026-05-20T11:18:37","guid":{"rendered":"https:\/\/gigz.pk\/cpp\/?post_type=lesson&#038;p=89"},"modified":"2026-05-22T08:07:11","modified_gmt":"2026-05-22T08:07:11","slug":"parameters-and-arguments","status":"publish","type":"lesson","link":"https:\/\/gigz.pk\/cpp\/?lesson=parameters-and-arguments","title":{"rendered":"Parameters and Arguments"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Parameters and arguments are important concepts in C++ functions. They allow functions to receive data and perform operations using different values.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What are Parameters?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Parameters are variables declared in a function definition. They act as placeholders to receive values when the function is called.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What are Arguments?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Arguments are the actual values passed to a function during a function call.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In simple words:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Parameters are defined in the function<\/li>\n\n\n\n<li>Arguments are passed when calling the function<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Syntax of Parameters and Arguments<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>return_type function_name(parameter_list);<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Example of Parameters and Arguments<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;<br>using namespace std;<br><br>void display(int age) {<br>    cout &lt;&lt; \"Age: \" &lt;&lt; age;<br>}<br><br>int main() {<br>    display(20);<br><br>    return 0;<br>}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Understanding the Example<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>int age<\/code> \u2192 Parameter<\/li>\n\n\n\n<li><code>20<\/code> \u2192 Argument<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">The argument value is passed into the parameter.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Example with Multiple Parameters<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;<br>using namespace std;<br><br>int add(int a, int b) {<br>    return a + b;<br>}<br><br>int main() {<br>    cout &lt;&lt; add(5, 3);<br><br>    return 0;<br>}<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Here:<\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>int a, int b<\/code> \u2192 Parameters<\/li>\n\n\n\n<li><code>5, 3<\/code> \u2192 Arguments<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Types of Parameters in C++<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Formal Parameters<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Variables declared inside the function definition.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>int add(int a, int b)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">2. Actual Parameters (Arguments)<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Values passed during function call.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add(5, 3)<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Default Parameters<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">C++ allows default values for parameters.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>#include &lt;iostream&gt;<br>using namespace std;<br><br>void greet(string name = \"Guest\") {<br>    cout &lt;&lt; \"Hello \" &lt;&lt; name;<br>}<br><br>int main() {<br>    greet();<br><br>    return 0;<br>}<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Output<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>Hello Guest<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Why Parameters and Arguments are Important<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">They are important because they:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Allow functions to handle different data<\/li>\n\n\n\n<li>Improve code flexibility<\/li>\n\n\n\n<li>Reduce code repetition<\/li>\n\n\n\n<li>Support reusable programming<\/li>\n\n\n\n<li>Make programs more dynamic<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Real-Life Example<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Think of a food order:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Menu item name acts like a parameter<\/li>\n\n\n\n<li>Customer&#8217;s selected item acts like an argument<\/li>\n<\/ul>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1779437292410\"><strong class=\"schema-faq-question\"><\/strong> <p class=\"schema-faq-answer\"><\/p> <\/div> <\/div>\n\n\n\n<p class=\"wp-block-paragraph\">The same system works with different inputs.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Parameters and arguments in C++ help functions receive and process data efficiently. Parameters define what a function expects, while arguments provide the actual values. Understanding them is essential for writing reusable and flexible programs.<\/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\">Intermediate C++ > Functions > Parameters and Arguments<\/span><\/span><\/div>","protected":false},"menu_order":21,"template":"","class_list":["post-89","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>Parameters and Arguments - Learn C++Language with GiGz.PK<\/title>\n<meta name=\"description\" content=\"Learn C++ parameters and arguments with examples to understand how functions receive and use data for flexible programming.\" \/>\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=\"Parameters and Arguments - Learn C++Language with GiGz.PK\" \/>\n<meta property=\"og:description\" content=\"Learn C++ parameters and arguments with examples to understand how functions receive and use data for flexible programming.\" \/>\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-22T08:07:11+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=parameters-and-arguments\",\"url\":\"https:\\\/\\\/gigz.pk\\\/\",\"name\":\"Parameters and Arguments - Learn C++Language with GiGz.PK\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/gigz.pk\\\/cpp\\\/#website\"},\"datePublished\":\"2026-05-20T11:18:37+00:00\",\"dateModified\":\"2026-05-22T08:07:11+00:00\",\"description\":\"Learn C++ parameters and arguments with examples to understand how functions receive and use data for flexible programming.\",\"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\":\"Intermediate C++ > Functions > Parameters and Arguments\"}]},{\"@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":"Parameters and Arguments - Learn C++Language with GiGz.PK","description":"Learn C++ parameters and arguments with examples to understand how functions receive and use data for flexible programming.","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":"Parameters and Arguments - Learn C++Language with GiGz.PK","og_description":"Learn C++ parameters and arguments with examples to understand how functions receive and use data for flexible programming.","og_url":"https:\/\/gigz.pk\/","og_site_name":"Learn C++Language with GiGz.PK","article_modified_time":"2026-05-22T08:07:11+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=parameters-and-arguments","url":"https:\/\/gigz.pk\/","name":"Parameters and Arguments - Learn C++Language with GiGz.PK","isPartOf":{"@id":"https:\/\/gigz.pk\/cpp\/#website"},"datePublished":"2026-05-20T11:18:37+00:00","dateModified":"2026-05-22T08:07:11+00:00","description":"Learn C++ parameters and arguments with examples to understand how functions receive and use data for flexible programming.","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":"Intermediate C++ > Functions > Parameters and Arguments"}]},{"@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\/89","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=89"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}