{"id":1156,"date":"2016-06-25T13:10:41","date_gmt":"2016-06-25T13:10:41","guid":{"rendered":"http:\/\/tutorialsclass.com\/?p=1156"},"modified":"2020-06-18T07:05:39","modified_gmt":"2020-06-18T07:05:39","slug":"c-variables","status":"publish","type":"post","link":"https:\/\/tutorialsclass.com\/c-variables\/","title":{"rendered":"C Variables"},"content":{"rendered":"\n<p>In simple words, variable is a name given to memory box with a name, where we can &#8220;store&#8221; some value. Its value can be changed depending upon conditions and it can be reused many times.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>A variable can support different type of data such as integer, float, character etc<\/li><li>Value of variables can be changed according to the information passed to the program.<\/li><li>You can perform different set of operation to the variables.<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Rules for naming C Variable<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>A Variable name must begin with letter or underscore.<\/li><li>Variables are case sensitive<\/li><li>You can use letters &amp; digits in variable names.<\/li><li>No special symbols can be used other than underscore.<\/li><li>sum, city, person_2, _value are some examples for Variable name<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Characters allowed in C variable name:<\/h3>\n\n\n\n<p>You can use Underscore<code>(_)<\/code>, Capital Letters<code> ( A \u2013 Z )<\/code>, Small Letters <code>( a \u2013 z )<\/code> and Digits <code>( 0 \u2013 9 )<\/code> while choosing a variable name. Blanks, Commas and other special symbols are not allowed in variable naming. Variable name Should not be Reserved Word.<\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Example of Valid or Invalid Variable Names<\/h3>\n\n\n\n<p>These are some of the examples of valid variable names for city<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li><code>city<\/code><\/li><li><code>City<\/code><\/li><li><code>City1<\/code><\/li><li><code>_City<\/code><\/li><li><code>my_city<\/code><\/li><li><code>city_1<\/code><\/li><li><code>city_of_person<\/code><\/li><li><code>status_flag<\/code><\/li><li><code>_city1<\/code><\/li><\/ul>\n\n\n\n<h4 class=\"wp-block-heading\">Invalid Variable Names<\/h4>\n\n\n\n<ul class=\"wp-block-list\"><li><code>1city<\/code><\/li><li><code>1_city<\/code><\/li><li><code>city 1<\/code><\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">Declaring &amp; initializing C Variable<\/h3>\n\n\n\n<ul class=\"wp-block-list\"><li>First, you need to declare a variable in the C program before to use it.<\/li><li>Memory space is not created for a variable during a declaration. It happens only on the variable definitions.<\/li><li>Variable initialization assigs a value to the variable.<\/li><\/ul>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<figure class=\"wp-block-table\"><table><tbody><tr><th>S.No<\/th><th>Type<\/th><th>Syntax<\/th><th>Example<\/th><\/tr><tr><td>1.<\/td><td>Variable declaration<\/td><td>data_type variable_name;<\/td><td>int x, y, z; char ch;<\/td><\/tr><tr><td>2.<\/td><td>Variable initialization<\/td><td>data_type variable_name = value;<\/td><td>int x = 10, y = 20; ch=\u2019l\u2019;<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h3 class=\"wp-block-heading\">Example of Variable in C Programming<\/h3>\n\n\n\n<p>Here is the simple example of C Variable:<\/p>\n\n\n\n<pre class=\"wp-block-code language-c\"><code>#include&lt;stdio.h>\nint main()\n{\n\t\/* Variable declaration *\/\n\tint num;\n\t\/* Variable initialization *\/\n\tnum = 10;\n\t\/* print value of a variable *\/ printf(\"Number is: %d \\n\", num); \n\treturn 0;\n}<\/code><\/pre>\n\n\n\t<div class=\"tc-browser-container\">\r\n\t\t<div class=\"top\">\r\n\t\t\t<span class=\"tc-circle\"><\/span>\r\n\t\t\t<span class=\"tc-circle\"><\/span>\r\n\t\t\t<span class=\"tc-circle\"><\/span>\r\n\t\t\t<span class=\"tc-browser-title\"> Tutorials Class - Output Window <\/span>\r\n\t\t<\/div>\r\n\t\t<div class=\"tc-browser-content\"> <p>\nNumber is=10<\/p>\n <\/div>\r\n\t<\/div>\r\n\n","protected":false},"excerpt":{"rendered":"<p>In simple words, variable is a name given to memory box with a name, where we can &#8220;store&#8221; some value. Its value can be changed depending upon conditions and it can be&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[14],"tags":[],"keywords":[],"class_list":["post-1156","post","type-post","status-publish","format-standard","hentry","category-c"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.1.1 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Variables in C Language - Declaring &amp; initializing C Variable<\/title>\n<meta name=\"description\" content=\"Variable is a name given to memory box with a name to &quot;store&quot; some value. Learn How to use Variable in C Language - Declaring &amp; initializing C Variables\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/tutorialsclass.com\/c-variables\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Variables in C Language - Declaring &amp; initializing C Variable\" \/>\n<meta property=\"og:description\" content=\"Variable is a name given to memory box with a name to &quot;store&quot; some value. Learn How to use Variable in C Language - Declaring &amp; initializing C Variables\" \/>\n<meta property=\"og:url\" content=\"https:\/\/tutorialsclass.com\/c-variables\/\" \/>\n<meta property=\"og:site_name\" content=\"Tutorials Class\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/tutorialsclass\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-25T13:10:41+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2020-06-18T07:05:39+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png\" \/>\n\t<meta property=\"og:image:width\" content=\"600\" \/>\n\t<meta property=\"og:image:height\" content=\"600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Tutorials Class\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@TutorialsClass\" \/>\n<meta name=\"twitter:site\" content=\"@TutorialsClass\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Tutorials Class\" \/>\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:\/\/tutorialsclass.com\/c-variables\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/tutorialsclass.com\/c-variables\/\"},\"author\":{\"name\":\"Tutorials Class\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e\"},\"headline\":\"C Variables\",\"datePublished\":\"2016-06-25T13:10:41+00:00\",\"dateModified\":\"2020-06-18T07:05:39+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/tutorialsclass.com\/c-variables\/\"},\"wordCount\":280,\"publisher\":{\"@id\":\"https:\/\/tutorialsclass.com\/#organization\"},\"articleSection\":[\"C Tutorial\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/tutorialsclass.com\/c-variables\/\",\"url\":\"https:\/\/tutorialsclass.com\/c-variables\/\",\"name\":\"Variables in C Language - Declaring & initializing C Variable\",\"isPartOf\":{\"@id\":\"https:\/\/tutorialsclass.com\/#website\"},\"datePublished\":\"2016-06-25T13:10:41+00:00\",\"dateModified\":\"2020-06-18T07:05:39+00:00\",\"description\":\"Variable is a name given to memory box with a name to \\\"store\\\" some value. Learn How to use Variable in C Language - Declaring & initializing C Variables\",\"breadcrumb\":{\"@id\":\"https:\/\/tutorialsclass.com\/c-variables\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/tutorialsclass.com\/c-variables\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/tutorialsclass.com\/c-variables\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/tutorialsclass.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Learn\",\"item\":\"https:\/\/tutorialsclass.com\/learn\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"C Tutorial\",\"item\":\"https:\/\/tutorialsclass.com\/learn\/c\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"C Variables\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/tutorialsclass.com\/#website\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"name\":\"Tutorials Class\",\"description\":\"Online Tutorials for Beginners\",\"publisher\":{\"@id\":\"https:\/\/tutorialsclass.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/tutorialsclass.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/tutorialsclass.com\/#organization\",\"name\":\"Tutorials Class\",\"url\":\"https:\/\/tutorialsclass.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"contentUrl\":\"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png\",\"width\":442,\"height\":94,\"caption\":\"Tutorials Class\"},\"image\":{\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/tutorialsclass\",\"https:\/\/x.com\/TutorialsClass\",\"https:\/\/in.pinterest.com\/merientinfotech\/boards\/\",\"https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e\",\"name\":\"Tutorials Class\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/tutorialsclass.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g\",\"caption\":\"Tutorials Class\"},\"sameAs\":[\"tcadmin\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Variables in C Language - Declaring & initializing C Variable","description":"Variable is a name given to memory box with a name to \"store\" some value. Learn How to use Variable in C Language - Declaring & initializing C Variables","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:\/\/tutorialsclass.com\/c-variables\/","og_locale":"en_US","og_type":"article","og_title":"Variables in C Language - Declaring & initializing C Variable","og_description":"Variable is a name given to memory box with a name to \"store\" some value. Learn How to use Variable in C Language - Declaring & initializing C Variables","og_url":"https:\/\/tutorialsclass.com\/c-variables\/","og_site_name":"Tutorials Class","article_publisher":"https:\/\/www.facebook.com\/tutorialsclass","article_published_time":"2016-06-25T13:10:41+00:00","article_modified_time":"2020-06-18T07:05:39+00:00","og_image":[{"width":600,"height":600,"url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/07\/tutorials-class-logo.png","type":"image\/png"}],"author":"Tutorials Class","twitter_card":"summary_large_image","twitter_creator":"@TutorialsClass","twitter_site":"@TutorialsClass","twitter_misc":{"Written by":"Tutorials Class","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/tutorialsclass.com\/c-variables\/#article","isPartOf":{"@id":"https:\/\/tutorialsclass.com\/c-variables\/"},"author":{"name":"Tutorials Class","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e"},"headline":"C Variables","datePublished":"2016-06-25T13:10:41+00:00","dateModified":"2020-06-18T07:05:39+00:00","mainEntityOfPage":{"@id":"https:\/\/tutorialsclass.com\/c-variables\/"},"wordCount":280,"publisher":{"@id":"https:\/\/tutorialsclass.com\/#organization"},"articleSection":["C Tutorial"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/tutorialsclass.com\/c-variables\/","url":"https:\/\/tutorialsclass.com\/c-variables\/","name":"Variables in C Language - Declaring & initializing C Variable","isPartOf":{"@id":"https:\/\/tutorialsclass.com\/#website"},"datePublished":"2016-06-25T13:10:41+00:00","dateModified":"2020-06-18T07:05:39+00:00","description":"Variable is a name given to memory box with a name to \"store\" some value. Learn How to use Variable in C Language - Declaring & initializing C Variables","breadcrumb":{"@id":"https:\/\/tutorialsclass.com\/c-variables\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/tutorialsclass.com\/c-variables\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/tutorialsclass.com\/c-variables\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/tutorialsclass.com\/"},{"@type":"ListItem","position":2,"name":"Learn","item":"https:\/\/tutorialsclass.com\/learn\/"},{"@type":"ListItem","position":3,"name":"C Tutorial","item":"https:\/\/tutorialsclass.com\/learn\/c\/"},{"@type":"ListItem","position":4,"name":"C Variables"}]},{"@type":"WebSite","@id":"https:\/\/tutorialsclass.com\/#website","url":"https:\/\/tutorialsclass.com\/","name":"Tutorials Class","description":"Online Tutorials for Beginners","publisher":{"@id":"https:\/\/tutorialsclass.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/tutorialsclass.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/tutorialsclass.com\/#organization","name":"Tutorials Class","url":"https:\/\/tutorialsclass.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/","url":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","contentUrl":"https:\/\/tutorialsclass.com\/wp-content\/uploads\/2020\/05\/tutorials-class-logo.png","width":442,"height":94,"caption":"Tutorials Class"},"image":{"@id":"https:\/\/tutorialsclass.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/tutorialsclass","https:\/\/x.com\/TutorialsClass","https:\/\/in.pinterest.com\/merientinfotech\/boards\/","https:\/\/www.youtube.com\/channel\/UCzbpQXlqec-bQf1_kwrTuoA"]},{"@type":"Person","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/f7d4f67fc9721ef3ea91cb21aaf89e3e","name":"Tutorials Class","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/tutorialsclass.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/346276d8e1600eec36df1bf9adcf78bf1eabb87fc0a79250e0565a88809b8f14?s=96&d=mm&r=g","caption":"Tutorials Class"},"sameAs":["tcadmin"]}]}},"_links":{"self":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/1156","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/comments?post=1156"}],"version-history":[{"count":5,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/1156\/revisions"}],"predecessor-version":[{"id":6376,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/posts\/1156\/revisions\/6376"}],"wp:attachment":[{"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/media?parent=1156"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/categories?post=1156"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/tags?post=1156"},{"taxonomy":"keywords","embeddable":true,"href":"https:\/\/tutorialsclass.com\/wp-json\/wp\/v2\/keywords?post=1156"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}