{"id":7890,"date":"2022-09-10T20:31:03","date_gmt":"2022-09-10T15:01:03","guid":{"rendered":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/"},"modified":"2022-09-10T20:31:03","modified_gmt":"2022-09-10T15:01:03","slug":"solved-when-do-you-use-the-operator-in-c-language","status":"publish","type":"post","link":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/","title":{"rendered":"[Solved] When do you use the &#038; operator in C language?"},"content":{"rendered":"<p> [ad_1]<br \/>\n<\/p>\n<div id=\"answer-72194132\" class=\"answer js-answer accepted-answer js-accepted-answer\" data-answerid=\"72194132\" data-parentid=\"72194024\" data-score=\"4\" data-position-on-page=\"1\" data-highest-scored=\"1\" data-question-has-accepted-highest-score=\"1\" itemprop=\"acceptedAnswer\" itemscope itemtype=\"https:\/\/schema.org\/Answer\">\n<div class=\"post-layout\">\n<div class=\"votecell post-layout--left\"><\/div>\n<div class=\"answercell post-layout--right\">\n<div class=\"s-prose js-post-body\" itemprop=\"text\">\n<p>Generally, you use just the name of an object, like <code>i<\/code>, when you want its value. In <code>printf(\"%d \", i)<\/code>, we want <code>printf<\/code> to print the value of <code>i<\/code>, so we just pass <code>i<\/code>.<\/p>\n<p>In <code>scanf(\"%d\", \u2026)<\/code>, we do not want to tell <code>scanf<\/code> what the value of <code>i<\/code> is. We want <code>scanf<\/code> to change <code>i<\/code>. To do this, we must provide <code>scanf<\/code> with some reference to <code>i<\/code>. To do this, we give <code>scanf<\/code> the address of <code>i<\/code>, with <code>scanf(\"%d\", &amp;i)<\/code>.<\/p>\n<p>So, when passing an argument to a routine, you will use <code>&amp;<\/code> if you want to pass the address of an object to that routine. If you want to pass the value, you will not use <code>&amp;<\/code>.<\/p>\n<p>Technically, whenever we write <code>i<\/code> in an expression, that designates the object <code>i<\/code>, not its value. However, in many cases, an object is automatically converted to its value. So, in <code>printf(\"%d\", i*3);<\/code>, the object <code>i<\/code> is automatically converted to its value, and then the value is multiplied by 3. This is an automatic part of the language, and it works well, so you rarely have to think about it.<\/p>\n<p>This automatic conversion of an object to its value is called <em>lvalue conversion<\/em>. There are some exceptions to it. In these cases, we want to use the object <code>i<\/code> rather than its value:<\/p>\n<ul>\n<li>In an assignment, like <code>i = 3;<\/code>, we want the assignment to change <code>i<\/code>.<\/li>\n<li>In <code>sizeof i<\/code>, we want the size of the object <code>i<\/code>, not its value or the size of its value.<\/li>\n<li>In <code>&amp;i<\/code>, we want the address of <code>i<\/code>, not the address of its value.<\/li>\n<li>In <code>++i<\/code>, <code>i++<\/code>, <code>--i<\/code>, and <code>i--<\/code>, we want to modify the object <code>i<\/code>.<\/li>\n<\/ul>\n<p>In all of those cases, the automatic conversion of an object to its value does not occur. This is part of the design of the C language.<\/p>\n<p>There are two more exceptions:<\/p>\n<ul>\n<li>With the operator for accessing a member of a structure or union, <code>.<\/code>, the left operand is not converted to its value. So, if <code>s<\/code> is a structure, then, in <code>s.i<\/code>, <code>s<\/code> remains a designation of the structure, and the expression <code>s.i<\/code> then designates the member <code>i<\/code> of that structure. (To continue evaluation of the expression this appears in, that member is then converted to its value, unless it also appears in one of these exceptions.)<\/li>\n<li>If the object is an array, it is not converted to its value. (By separate rules for arrays, it is often converted to a pointer to its first element.)<\/li>\n<\/ul>\n<\/div>\n<div class=\"mt24\"><\/div>\n<\/div>\n<p>            <span class=\"d-none\" itemprop=\"commentCount\">1<\/span> <\/p><\/div>\n<\/div>\n<p>[ad_2]<\/p>\n<p>solved When do you use the &#038; operator in C language? <\/p>\n","protected":false},"excerpt":{"rendered":"<p>[ad_1] Generally, you use just the name of an object, like i, when you want its value. In printf(&#8220;%d &#8220;, i), we want printf to print the value of i, so we just pass i. In scanf(&#8220;%d&#8221;, \u2026), we do not want to tell scanf what the value of i is. We want scanf to &#8230; <a title=\"[Solved] When do you use the &#038; operator in C language?\" class=\"read-more\" href=\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/\" aria-label=\"More on [Solved] When do you use the &#038; operator in C language?\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[320],"tags":[324],"class_list":["post-7890","post","type-post","status-publish","format-standard","hentry","category-solved","tag-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>[Solved] When do you use the &amp; operator in C language? - JassWeb<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"[Solved] When do you use the &amp; operator in C language? - JassWeb\" \/>\n<meta property=\"og:description\" content=\"[ad_1] Generally, you use just the name of an object, like i, when you want its value. In printf(&quot;%d &quot;, i), we want printf to print the value of i, so we just pass i. In scanf(&quot;%d&quot;, \u2026), we do not want to tell scanf what the value of i is. We want scanf to ... Read more\" \/>\n<meta property=\"og:url\" content=\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/\" \/>\n<meta property=\"og:site_name\" content=\"JassWeb\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-10T15:01:03+00:00\" \/>\n<meta name=\"author\" content=\"Kirat\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Kirat\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/\"},\"author\":{\"name\":\"Kirat\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\"},\"headline\":\"[Solved] When do you use the &#038; operator in C language?\",\"datePublished\":\"2022-09-10T15:01:03+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/\"},\"wordCount\":392,\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"keywords\":[\"c++\"],\"articleSection\":[\"Solved\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/\",\"url\":\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/\",\"name\":\"[Solved] When do you use the & operator in C language? - JassWeb\",\"isPartOf\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#website\"},\"datePublished\":\"2022-09-10T15:01:03+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/jassweb.com\/solved\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"[Solved] When do you use the &#038; operator in C language?\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/jassweb.com\/solved\/#website\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"name\":\"JassWeb\",\"description\":\"Build High-quality Websites\",\"publisher\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/jassweb.com\/solved\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/jassweb.com\/solved\/#organization\",\"name\":\"Jass Web\",\"url\":\"https:\/\/jassweb.com\/solved\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"contentUrl\":\"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png\",\"width\":693,\"height\":132,\"caption\":\"Jass Web\"},\"image\":{\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31\",\"name\":\"Kirat\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"contentUrl\":\"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586\",\"caption\":\"Kirat\"},\"sameAs\":[\"http:\/\/jassweb.com\"],\"url\":\"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"[Solved] When do you use the & operator in C language? - JassWeb","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:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/","og_locale":"en_US","og_type":"article","og_title":"[Solved] When do you use the & operator in C language? - JassWeb","og_description":"[ad_1] Generally, you use just the name of an object, like i, when you want its value. In printf(\"%d \", i), we want printf to print the value of i, so we just pass i. In scanf(\"%d\", \u2026), we do not want to tell scanf what the value of i is. We want scanf to ... Read more","og_url":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/","og_site_name":"JassWeb","article_published_time":"2022-09-10T15:01:03+00:00","author":"Kirat","twitter_card":"summary_large_image","twitter_misc":{"Written by":"Kirat","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/#article","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/"},"author":{"name":"Kirat","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31"},"headline":"[Solved] When do you use the &#038; operator in C language?","datePublished":"2022-09-10T15:01:03+00:00","mainEntityOfPage":{"@id":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/"},"wordCount":392,"publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"keywords":["c++"],"articleSection":["Solved"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/","url":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/","name":"[Solved] When do you use the & operator in C language? - JassWeb","isPartOf":{"@id":"https:\/\/jassweb.com\/solved\/#website"},"datePublished":"2022-09-10T15:01:03+00:00","breadcrumb":{"@id":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/jassweb.com\/solved\/solved-when-do-you-use-the-operator-in-c-language\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/jassweb.com\/solved\/"},{"@type":"ListItem","position":2,"name":"[Solved] When do you use the &#038; operator in C language?"}]},{"@type":"WebSite","@id":"https:\/\/jassweb.com\/solved\/#website","url":"https:\/\/jassweb.com\/solved\/","name":"JassWeb","description":"Build High-quality Websites","publisher":{"@id":"https:\/\/jassweb.com\/solved\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/jassweb.com\/solved\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/jassweb.com\/solved\/#organization","name":"Jass Web","url":"https:\/\/jassweb.com\/solved\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/","url":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","contentUrl":"https:\/\/jassweb.com\/wp-content\/uploads\/2021\/02\/jass-website-logo-1.png","width":693,"height":132,"caption":"Jass Web"},"image":{"@id":"https:\/\/jassweb.com\/solved\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/65c9c7b7958150c0dc8371fa35dd7c31","name":"Kirat","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/jassweb.com\/solved\/#\/schema\/person\/image\/","url":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","contentUrl":"https:\/\/jassweb.com\/solved\/wp-content\/litespeed\/avatar\/1261af3c9451399fa1336d28b98ea3bb.jpg?ver=1776403586","caption":"Kirat"},"sameAs":["http:\/\/jassweb.com"],"url":"https:\/\/jassweb.com\/solved\/author\/jaspritsinghghumangmail-com\/"}]}},"_links":{"self":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/7890","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/comments?post=7890"}],"version-history":[{"count":0,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/posts\/7890\/revisions"}],"wp:attachment":[{"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/media?parent=7890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/categories?post=7890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/jassweb.com\/solved\/wp-json\/wp\/v2\/tags?post=7890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}