<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[C Programming මුල සිට ඉගෙනගනිමු (part 2 - Variables)]]></title><description><![CDATA[<p dir="auto">සුබ දවසක් ඔයාලට. අපි අද ලෑස්ති වෙන්නේ තවදුරටත්  C පිළිබඳ ඉගෙනගන්න. කලින් පෝස්ට් එකේදි මන් ඔයාලට කියලා දුන්නා C වල origin එකයි කොහොමද C programm එකක් code කරන එකයි.</p>
<p dir="auto">අද මන් බලාපොරොත්තු වෙන්නේ C programming වල එන variables ගැනයි ඒවා ක්‍රියාත්මක වෙන විදිහයි කියලා දෙන්න.</p>
<p dir="auto"><strong>Variables</strong> (විචල්‍යයන්)</p>
<ul>
<li>සාමාන්‍ය සිංහල විව්‍යහාරයේදී variable එකක් නැත්තම් විචල්‍යයක් කියලා කියන්නේ යම් කිසි දත්තයක් ගබඩා කරගත් හැකි දෙයකටයි.</li>
</ul>
<pre><code>	උදා -:   x = 10 (මෙතන variable එක x වන අතර දත්තය 10 වේ)
	          apples = 5
		  උස = 172.5 cm
		  name = john
</code></pre>
<ul>
<li>
<p dir="auto">මෙම  variables වලයි  C programming වල එන variables වලයි ලොකු වෙනකක් නෑ. C programming වල variable එකක් කියන්නේ යම්කිසි programm එකක් භාවිතා කර<br />
දත්තයක් ගබඩා කල හැකි memory location එකක්.</p>
</li>
<li>
<p dir="auto">විශේෂත්වය වන්නේ අපේ variable එක අපි විශේෂ කරලා පෙන්නන්න ඕනා එය පූර්ණ සංඛ්‍යාවක්ද, දශම සංඛ්‍යාවක්ද නැත්නම් සංඛ්‍යාත්මක නොවන දෙයක්ද වන බව. එනම් අපි C වල variable වර්ග<br />
තුනක් ගැන කතා කරනවා</p>
<pre><code>  1. Integers(පූර්ණ සංඛ්‍යා)  - short    --&gt; -32,768 සිට 32,767 දක්වා සංඛ්‍යා ගබඩා කර ගත හැකිය.
  		              - int      --&gt; -2,147,483,648 සිට 2,147,483,647  දක්වා සංඛ්‍යා ගබඩා කර ගත හැකිය.
  			      - long int --&gt; -9223372036854775808 සිට 9223372036854775807 දක්වා සංඛ්‍යා ගබඩා කර ගත හැකිය.
  
  2. Real Numbers(දශම සංඛ්‍යා)  - float      --&gt; 1.2E-38 සිට 3.4E+38 දක්වා සංඛ්‍යා ගබඩා කර ගත හැකිය.
  				 - double      --&gt; 2.3E-308 සිට 1.7E+308 දක්වා සංඛ්‍යා ගබඩා කර ගත හැකිය.
  				 - long double --&gt; 3.4E-4932 සිට 1.1E+4932 දක්වා සංඛ්‍යා ගබඩා කර ගත හැකිය.
  						
  3. Characters(සංඛ්‍යාත්මක නොවන) - char --&gt; 'k', 'a', '@', '+' වැනි දෑ
</code></pre>
</li>
<li>
<p dir="auto">variable වර්ග ගණනාවක් තිබුනත් අපි ගොඩක් අවස්තා වලදී පාවිච්චි කරන්නේ <code>int, float, double, char</code> වර්ග පමණි</p>
</li>
</ul>
<p dir="auto">මේ ගැන වැඩි විස්තර දැන ගැනීමට අවශ්‍ය නම් මේ ලින්ක් එකට ගිහින් බලන්න --&gt; <a href="https://www.tutorialspoint.com/cprogramming/c_data_types.htm" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.tutorialspoint.com/cprogramming/c_data_types.htm</a></p>
<ul>
<li>අපි දැන් කතා කලා variable එකක් විශේෂ කරන්නේ කොහොමද කියලා. අපි දැන් කරන්න හදන්නේ variable එකක් ලිවීමේදී අනුගමනය කල යුතු නීති.</li>
</ul>
<pre><code>	වැරදි											නිවැරදි
int mymarks						      				int myMarks හෝ int my_marks

int 3cars (සංඛ්‍යාවකින් variable එකක් ආරම්භ කල නොහැක)			        int cars3

int my car(වචන අතර හිස්තැන් තිබිය නොහැක)					int my_car හෝ int myCar

int float, int return C වල භාවිතා වන වචන ලිවීමට නොහැක

විරාම ලකුණු භාවිතා කල නොහැකිය. (underscore(_)) එක හැර.
</code></pre>
<p dir="auto"><strong>තවද int Mark හා int mark යනු එකක් නොවේ variable වර්ග දෙකකි.</strong></p>
<p dir="auto">දැන් අපි variables භාවිතා කරලා programm එකක් ලියමු.</p>
<pre><code>#include&lt;stdio.h&gt;

int main(void){ 
	// මෙම ඇල ඉරි දෙකෙන් සිදුවන්නේ මම මේ ලියන එක කමෙන්ට් එකක් ලෙස දිස් වීමයි. programm එක run කරන විට මේ කමෙන්ට්ස්  run නොවේ. 
	
	int age = 23;
	float price = 10.50;
	char letter = 'a';        //char variable එකක් භාවිතා කරන විට තනි කොමා යටතේ වචන ලිවිය යුතු වේ. නමුත් මෙමගින් ලිවිය හැක්කේ එක් අකුරක් පමණි
	char name[20] = "Kalana"; //මෙම char variable එක මගින් අකුරු  එකකට වඩා ලිවිය හැකිය. ඔබට ලිවීමට අව්ශය අකුරු ගණන ඉලක්කමෙන් කොටු වරහන් තුල දැක්විය යුතුය.
	
	//අපි දැන් මේ ඉලක්කම් printf කිහිපයක් මගින් output කරමු.
	
	printf("Age is = %d    \n", age);    //%d යනු int variable එකේ අගය display කරන නිරූපකයයි.
	printf("Price is = %f  \n", price);  //%f යනු float variable එකේ අගය display කරන නිරූපකයයි.
	printf("Letter is = %c \n", letter); //%c , %s යනු char variable එකේ අගය display කරන නිරූපකයයි.
	printf("Name is = %s \n", name);
	
	/*
	පේලි එකකට
			වඩා
				කමෙන්ට් කල හැකිය
	*/
	
	return 0;
}	
</code></pre>
<p dir="auto">මේ code එක run කලාම අපිට ලැබෙන output එක වන්නේ.<br />
<img src="/assets/uploads/files/1574327704569-c-programm1-resized.png" alt="0_1574327704026_C programm1.PNG" class=" img-responsive img-markdown" /></p>
<p dir="auto"><strong>C programm එකක් windows වල  run කරන විදිහ මන් කලින් ලිපියේ සදහන් කලා --&gt;</strong> <a href="https://bit.ly/2O6rLXR" target="_blank" rel="noopener noreferrer nofollow ugc">https://bit.ly/2O6rLXR</a></p>
<p dir="auto"><strong>අමතර දැනුම</strong></p>
<ul>
<li><code>// </code>-: මෙම ලකුණින් කියවෙන්නේ එක් පේලියක් කමෙන්ට් කිරීමට හැකි බවයි.</li>
<li><code>/* */</code> -: මෙම ලකුණින් කියවෙන්නේ පේලි එකකට වඩ කමෙට් කල හැකි බවයි.</li>
<li><code>float</code> වලදී ඔබට ආසන්න දශම ස්තාන දෙකකට තිබීමට අවශ්‍යනම් <code>%0.2f</code> යොදන්න.</li>
</ul>
<p dir="auto"><strong>සාරාංශය</strong></p>
<ul>
<li>
<p dir="auto">C programm වල අප වැඩි වශයෙන් භාවිතා කරන variable types වන්නේ <code>int, float, double, char</code> වේ.</p>
</li>
<li>
<p dir="auto">C programm වල නිවැරදිව variable ලියන ආකාරය අපි ඉගෙනගත්තා</p>
</li>
<li>
<p dir="auto">මේ තියෙන්නේ අපි උදාහරණයක් වශයෙන් ගහපු code එක</p>
</li>
</ul>
<pre><code>#include&lt;stdio.h&gt;

int main(void){ 
	
	int age = 23;
	float price = 10.50;
	char letter = 'a'; 		
	char name[20] = "Kalana";
	
	printf("Age is = %d    \n", age);
	printf("Price is = %0.2f  \n", price);
	printf("Letter is = %c \n", letter);
	printf("Name is = %s \n", name);
	
	return 0;
}	
</code></pre>
<ul>
<li>C programm එකක් windows වල  run කරන විදිහ --&gt; <a href="https://bit.ly/2O6rLXR" target="_blank" rel="noopener noreferrer nofollow ugc">https://bit.ly/2O6rLXR</a></li>
</ul>
<p dir="auto">ඔබට අවශ්‍යනම් ඔබේ බ්‍රව්සර් එක හරහා online C programms run කරන්න පුලුවන්. එහෙම කරන්න පුලුවන් ලින්ක්ස් මන් පහතින් දාන්නම්</p>
<ul>
<li><a href="https://www.onlinegdb.com/online_c_compiler" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.onlinegdb.com/online_c_compiler</a></li>
<li><a href="https://www.tutorialspoint.com/compile_c_online.php" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.tutorialspoint.com/compile_c_online.php</a></li>
<li><a href="https://repl.it/languages/c" target="_blank" rel="noopener noreferrer nofollow ugc">https://repl.it/languages/c</a></li>
</ul>
<p dir="auto">සරලව මුල ඉදන්  C programming ඉගෙන ගන්න පුලුවන් හොදම site දෙකත් මන් දාන්නම්</p>
<ul>
<li><a href="https://www.geeksforgeeks.org/c-programming-language/" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.geeksforgeeks.org/c-programming-language/</a></li>
<li><a href="https://www.tutorialspoint.com/cprogramming/index.htm" target="_blank" rel="noopener noreferrer nofollow ugc">https://www.tutorialspoint.com/cprogramming/index.htm</a></li>
</ul>
<p dir="auto">මන් ඊළඟ ලිපියෙන් මේ variables අතර සිද්ධ වෙන  operations(+, -, /, *) ගැන කියලා දෙන්නම්.</p>
<p dir="auto">මම දාන ලිපි කෙටි වැඩීනම් පහලින් කමෙන්ට් එකක් දාන්න. තව අඩු පාඩු තියෙනවනම් ඒවත් දාන්න.</p>
]]></description><link>https://lankadevelopers.lk/topic/437/c-programming-ම-ල-ස-ට-ඉග-නගන-ම-part-2-variables</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 11:43:09 GMT</lastBuildDate><atom:link href="https://lankadevelopers.lk/topic/437.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 21 Nov 2019 09:25:58 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to C Programming මුල සිට ඉගෙනගනිමු (part 2 - Variables) on Fri, 22 Nov 2019 10:59:07 GMT]]></title><description><![CDATA[<p dir="auto">නියමයි බ්‍රෝ</p>
]]></description><link>https://lankadevelopers.lk/post/2512</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2512</guid><dc:creator><![CDATA[imadusanka]]></dc:creator><pubDate>Fri, 22 Nov 2019 10:59:07 GMT</pubDate></item><item><title><![CDATA[Reply to C Programming මුල සිට ඉගෙනගනිමු (part 2 - Variables) on Fri, 22 Nov 2019 05:55:42 GMT]]></title><description><![CDATA[<p dir="auto">supiri bro</p>
]]></description><link>https://lankadevelopers.lk/post/2511</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2511</guid><dc:creator><![CDATA[dev_lak]]></dc:creator><pubDate>Fri, 22 Nov 2019 05:55:42 GMT</pubDate></item><item><title><![CDATA[Reply to C Programming මුල සිට ඉගෙනගනිමු (part 2 - Variables) on Thu, 21 Nov 2019 18:03:10 GMT]]></title><description><![CDATA[<p dir="auto">නියමයි bro දිගටම වැඩේ කරමු .</p>
]]></description><link>https://lankadevelopers.lk/post/2510</link><guid isPermaLink="true">https://lankadevelopers.lk/post/2510</guid><dc:creator><![CDATA[root]]></dc:creator><pubDate>Thu, 21 Nov 2019 18:03:10 GMT</pubDate></item></channel></rss>