<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-4715479829039663415</id><updated>2022-05-29T14:26:31.729+05:30</updated><category term="ASP.NET"/><category term="C Language"/><category term="C Theory"/><category term="C#"/><category term="Gridview"/><category term="ASPNET GRIDVIEW"/><category term="Project"/><category term="sql server"/><category term="C# Tutorials"/><category term="JQUERY"/><category term="ASPNET Project"/><category term="ASP.NET JQuery"/><category term="C Prog"/><category term="C# Project"/><category term="HTML5"/><category term="Interview Question and Answer"/><category term="VBNET"/><category term="comments"/><category term="JSON"/><category term="ASP.NET E-Mail"/><category term="Algorithm"/><category term="Image"/><category term="Static"/><category term="bootstrap"/><category term="ListBox"/><category term="Oops"/><category term="XML"/><category term="ASP.NET Encode Decode"/><category term="C# DataGrid"/><category term="DataGridView"/><category term="Excel"/><category term="Gmail"/><category term="JAVASCRIPT"/><category term="URL"/><category term="Barcode"/><category term="Book Inventory"/><category term="CheckBox"/><category term="Dropdownlist"/><category term="Interview Tips"/><category term="LOGIN Page"/><category term="NuGet"/><category term="RadioButtonList"/><category term="Security"/><category term="Serialization"/><category term="Speech Translator"/><category term="WebChat"/><category term="WhatsApp"/><category term="YahooMail"/><category term="constructor"/><category term="instance"/><category term="variable"/><title type='text'>DOTNET PROGRAMMER</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default?start-index=26&amp;max-results=25'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>210</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-2455251875058722677</id><published>2018-09-17T14:23:00.002+05:30</published><updated>2018-09-17T14:25:53.811+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>What is mean by Operator Precedence and Associativity in C Language?</title><content type='html'>&lt;h2&gt;Operator Precedence : &lt;/h2&gt;&lt;p&gt; Each operator in C has a precedence associated with it. This precedence is used to determine, how n expression involving more than one operator is evaluated.&lt;br/&gt; There are distinct levels of precedence and an operator may belong to one of these levels.  &lt;/p&gt;&lt;p&gt; The operators at the higher level of precedence are evaluated first and the operators of the same precedence are evaluated either from left to right or from right to left, depending upon the level. This is known as associativity property of an operator. &lt;/p&gt;&lt;h3&gt;Precedence of Arithmetic Operators: &lt;/h3&gt;&lt;p&gt; An arithmetic expression involving parenthesis will be evaluated from left to right using the rules of precedence of operators. There are two distinct priority levels of arithmetic operators in C. &lt;/p&gt;&lt;ul&gt; &lt;li&gt; High priority arithmetic operators are &lt;b&gt; *, /, %.&lt;/b&gt;&lt;/li&gt; &lt;li&gt; Low priority arithmetic operators are &lt;b&gt; +, -.&lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; The basic evaluation procedure includes two left - to -right passes through the expression. During the first pass, the high priority operators are applied as they are encountered. During the first pass, the high priority operators are applied as they are encountered. During the second pass, the low priority operators are applied as they are encountered. &lt;/p&gt;&lt;h2&gt;Program : it explains the precedence and associativity of arithmetic operators&lt;/h2&gt;&lt;pre&gt;&lt;br /&gt; #include stdio.h&lt;br /&gt; main()&lt;br /&gt;  {&lt;br /&gt;    float a = 9, b = 12, c = 3, x, y, z;&lt;br /&gt;    printf(&quot;Evaluation of expressions : &quot;);&lt;br /&gt;    x = a - b / 3 + c * 2 _ 1;&lt;br /&gt;    y = a - b / (3 + c) * (2 - 1);&lt;br /&gt;    z = a - (b / (3 + c) * 2) - 1;&lt;br /&gt;    printf(&quot;x = %f &quot;, x);&lt;br /&gt;    printf(&quot;y = %f &quot;, y);&lt;br /&gt;    printf(&quot;Z = %f &quot;, z);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;Output : &lt;br /&gt;&lt;br /&gt; x = 10.000   7 = 7.00000    z = 4.0000&lt;br /&gt;&lt;/pre&gt;&lt;h3&gt;Explaination : &lt;/h3&gt;&lt;p&gt; Consider, the epxression 1 &lt;b&gt;x = a - b / 3 + c * 2 - 1&lt;/b&gt; &lt;br/&gt;when a = 9, b = 12, c = 3 the statement becomes, &lt;b&gt; x = 9 - 12 / 3 + 3 * 2 - 1 &lt;/b&gt; &lt;br/&gt; The above expression is evaluated as follows : &lt;/p&gt;&lt;table class=&quot;table table-bordered&quot;&gt; &lt;tr&gt;   &lt;td&gt;First Pass: &lt;/td&gt;   &lt;td&gt;     Step 1 : x = 9 - 4 + 3 * 2 - 1 &lt;br/&gt;     Step 2 : x = 9 - 4 + 6 - 1    &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt;Second Pass: &lt;/td&gt;   &lt;td&gt;     Step 3 : x = 5 + 6 - 1 &lt;br/&gt;     Step 4 : x = 11 - 1 &lt;br/&gt;     Step 5 : x = 10    &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt;&lt;p&gt; Consider the expression 2 &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; y = a - b / (3 + c) * (2 - 1)&lt;br /&gt; y = 9 - 12 / (3 + 3) * (2 - 1)&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; When parentheses are used, the expressions within the parentheses assume highest priority. &lt;br/&gt; If two or more sets of parentheses appear one after the another, the expression contained in the left most set is evaluated first and the right most is the last. &lt;/p&gt;&lt;table class=&quot;table table-bordered&quot;&gt; &lt;tr&gt;   &lt;td&gt;First Pass: &lt;/td&gt;   &lt;td&gt;     Step 1 : y = 9 - 12 / 6 * (2 - 1) &lt;br/&gt;     Step 2 : y = 9 - 12 / 6 * 1    &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt;Second Pass: &lt;/td&gt;   &lt;td&gt;     Step 3 : y = 9 - 2 * 1 &lt;br/&gt;     Step 4 : y = 9 - 2 &lt;br/&gt;   &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt;Third Pass :&lt;/td&gt;  &lt;td&gt;     Step 5 : y = 7   &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Consider the expression 3 &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; z = a - (b / (3 + c) * 2) - 1&lt;br /&gt; z = 9 - (12 / (3 + 3) * 2) - 1&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The result is as follows &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; Step 1 : z = 9 - (12 / 6 * 2) - 1&lt;br /&gt; Step 2 : z = 9 - (2 * 2) - 1&lt;br /&gt; Step 3 : z = 9 - 4 -1&lt;br /&gt; Step 4 : z = 5 - 1&lt;br /&gt; Step 5 : z = 4&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; parentheses can be nested, in such cases evaluation will be done from the innermost. &lt;/p&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2018/09/what-is-mean-by-operator-precedence-and-associativity.html" title="What is mean by Operator Precedence and Associativity in C Language?"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/2455251875058722677/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2018/09/what-is-mean-by-operator-precedence-and-associativity.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/2455251875058722677'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/2455251875058722677'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2018/09/what-is-mean-by-operator-precedence-and-associativity.html' title='What is mean by Operator Precedence and Associativity in C Language?'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-2215886349748606850</id><published>2018-09-17T13:45:00.000+05:30</published><updated>2018-09-17T13:45:47.220+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Explain explicit type conversion in C Language while evaluating expressions with examples?</title><content type='html'>&lt;h2&gt;Explicit Casting&lt;/h2&gt;&lt;p&gt; There are instances when we want to force a type conversion in a way that is different form the automatic conversion. For example, the calculate of ratio of females to males in a town is, &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;  ratio = female_number / male_number&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; Since female_number and male_number are declared as integers in the program, the decimal part of the result of the division would be lost and ration would represent a wrong figure. This problem can be solved by converting locally one of the variables to the floating point as shown below: &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; ratio = (float) female_number / male_number&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; The operator (float) converts the female_number to floating point for the purpose of evaluation of the expression. Then using the rule of automatic conversion, the division is performed in floating point mode, thus retaining the fractional part of result. &lt;/p&gt;&lt;p&gt; We can note that the operator (float) does not affect the value of the variable female number. Also, the type of female_number remains as int in the other parts of the program. &lt;br/&gt; The general form of a cast is : &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; (type - name) expression&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; Where type-name is one of the standard C data types. &lt;/p&gt;The expression may be a constant, variable or an expression. &lt;br/&gt; Casting can be used to round - ff a given value. &lt;pre&gt;&lt;br /&gt; x = (int) (y + 0.5);&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; if y is 27.6, y + 0.5 is 28.1 and on casting, the result becomes 28, the value that is assigned to x. &lt;br/&gt;When the higher type of data is converted into lower type data, then its value may be truncated. &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;Example - 1:&lt;br /&gt;   int i ;&lt;br /&gt;   double k = 4.5350;&lt;br /&gt;   i = k;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; Now the variable i consists of 4. The remaining data gets truncated. This process is also called narrowing. &lt;/p&gt;&lt;h3&gt;Example - 2 : Program using explicit type casting &lt;/h3&gt;&lt;pre&gt;&lt;br /&gt; #include &lt;stdio.h&gt;&lt;br /&gt; main()&lt;br /&gt; {&lt;br /&gt;  int a = 123;&lt;br /&gt;  float b = 1.234;&lt;br /&gt;  double c = 12456.123456789;&lt;br /&gt;  long double d = 12345678.123456789123;&lt;br /&gt;  printf(&quot;The value of integer a in float is %f \n&quot;, (float) a);&lt;br /&gt;  printf(&quot;The value of float b in int is %d \n&quot;, (int) b);&lt;br /&gt;  printf(&quot;The value of double c in int is %d \n&quot;, (int) c);&lt;br /&gt;  printf(&quot;The value of float c in double is %lf \n&quot;, (double) b);&lt;br /&gt;  printf(&quot;The value of long double c in int is %d \n&quot;, (int) d);&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt;Output : &lt;br /&gt;&lt;br /&gt; The value of integer a in float is 12.000000&lt;br /&gt; The value of float b in int is 1&lt;br /&gt; The value of double c in int is 12456&lt;br /&gt; The value of float b in double is 1.234000&lt;br /&gt; The value of long double c in int is 24910&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; In the last statement, long double will be first converted in to integer.&lt;br/&gt; The integer value is 12345678, it exceeds the integer range. The value 12345678 will be converted to 24910, which is within the integer range. &lt;/p&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2018/09/explain-explicit-type-conversion-in-c-language-while-evaluating-expression-with-examples.html" title="Explain explicit type conversion in C Language while evaluating expressions with examples?"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/2215886349748606850/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2018/09/explain-explicit-type-conversion-in-c-language-while-evaluating-expression-with-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/2215886349748606850'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/2215886349748606850'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2018/09/explain-explicit-type-conversion-in-c-language-while-evaluating-expression-with-examples.html' title='Explain explicit type conversion in C Language while evaluating expressions with examples?'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-4163680653107950656</id><published>2018-09-15T16:37:00.002+05:30</published><updated>2018-09-15T16:42:39.537+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Explain Implicit type conversion in C Language while evaluating expressions with examples</title><content type='html'>&lt;p&gt; There are two types of castings or conversions  &lt;ol&gt;   &lt;li&gt; Implicity Casting&lt;/li&gt;   &lt;li&gt; Explicit Casting&lt;/li&gt; &lt;/ol&gt;&lt;/p&gt;&lt;h3&gt;Implicity Casting&lt;/h3&gt;&lt;p&gt; C permits mixing of constants and variables of different types in an expression. C automatically converts any intermediate values to the proper type so that the expression can be evaluated without losing any significance. This automatica conversion is known as &lt;b&gt;implicit type conversion.&lt;/b&gt;&lt;/p&gt;&lt;p&gt; When the data type of smaller size is converted into higher size, implicit casting is done. It will be done by the compiler itself. If the operands are of different types, the lower type is automatically converted to higher types and the result will be of higher type. The result of expression is then converted to the type of variable at left hand side of the assignment operator. &lt;/p&gt;&lt;h3&gt;Rules for implicit type conversion.&lt;/h3&gt;&lt;ul&gt; &lt;li&gt; All short and char are automatically converted in to int.&lt;/li&gt; &lt;li&gt; If one of the operands is long double, the other will be converted to long double and the result will be long double.&lt;/li&gt; &lt;li&gt; else, if one of the operands is double, the other will be converted to double and the result will be double.&lt;/li&gt; &lt;li&gt; else, if one of the operands is float, the other will be concerted to float and the result will be float.&lt;/li&gt; &lt;li&gt; else, if one of the operands is long int and the other is unsigned int, then   &lt;ol&gt;    &lt;li&gt; if unsigned int can be converted to long int, the unsigned int operand will be converted as such and the result will be long int.&lt;/li&gt;    &lt;li&gt; else, both operands will be converted to unsigned long in and the result will be unsigned long int.&lt;/li&gt;  &lt;/ol&gt; &lt;/li&gt; &lt;li&gt; else, if one of the operands is long int, the other will be converted to long int and the result will be long int.&lt;/li&gt; &lt;li&gt; else, if one of the operands is unsigned int, the other will be converted to unsigned int and the result will be unsigned int.&lt;/li&gt;&lt;/ul&gt;&lt;h3&gt;Example - 1 &lt;/h3&gt;&lt;pre&gt;&lt;br /&gt; int i;&lt;br /&gt; char c = &#39;5&#39;;&lt;br /&gt; i = c;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; This process is also called widening, because here the lower data type value is assigned to higher data type. &lt;/p&gt;&lt;h3&gt;Example - 2 &lt;/h3&gt;&lt;pre&gt;&lt;br /&gt; int i;&lt;br /&gt; float f;&lt;br /&gt; double d;&lt;br /&gt; int j = i * d + f/i;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; In the given expression, &lt;b&gt;j = i * d + f/i;&lt;/b&gt; the evaluation is done as follows.  &lt;/p&gt;&lt;p&gt; &lt;b&gt;*&lt;/b&gt; and / have higher precedence, so &lt;b&gt;i * d &lt;/b&gt; and &lt;b&gt;f / i&lt;/b&gt; are evaluated first. &lt;/p&gt;&lt;ul&gt; &lt;li&gt; In sub expression i * d, i is of type integer and d is of type double. So i is converted to double data type (since, double is having higher precedence than integer) &lt;/li&gt; &lt;li&gt; In sub expression &lt;b&gt;f / i&lt;/b&gt;, f is of type float and i is of type integer. So i is converted to float data type.&lt;br/&gt;      So, now &lt;b&gt; j =&lt;/b&gt; double data type + float data type.&lt;/li&gt; &lt;li&gt; In this expression, float data type is converted to double data type(Since, double is having higher precedence than float). &lt;/li&gt; &lt;li&gt; In this assignment statement, &lt;b&gt;j&lt;/b&gt; is of type integer so the double type data is converted to integer type (the type of LHS of assignment Operator).&lt;/li&gt;&lt;/ul&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2018/09/explain-implicit-type-conversion-in-c-language-while-evaluating-expression-with-examples.html" title="Explain Implicit type conversion in C Language while evaluating expressions with examples"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/4163680653107950656/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2018/09/explain-implicit-type-conversion-in-c-language-while-evaluating-expression-with-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/4163680653107950656'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/4163680653107950656'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2018/09/explain-implicit-type-conversion-in-c-language-while-evaluating-expression-with-examples.html' title='Explain Implicit type conversion in C Language while evaluating expressions with examples'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-8386335632152785434</id><published>2018-09-15T16:13:00.000+05:30</published><updated>2018-09-15T16:13:02.982+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>what do you mean by type conversion in C Language or why it is necessary?</title><content type='html'>&lt;h1&gt;Type Conversion : &lt;/h1&gt;&lt;p&gt; As the name suggests, type conversion refers to conversion of data from one form to another. Type Conversion is one of the most important aspects of C programming, where programmers are prone to commit errors. Hence, care should be taken that the code written, obeys the principles of type conversion. &lt;/p&gt;&lt;h2&gt;Evaluation of expressions in Mixed Mode Arithmetic :&lt;/h2&gt;&lt;p&gt;  When an expression consists of different types of variables, C - Compiler follows rules of type conversion. &lt;/p&gt;&lt;table class=&quot;table table-bordered&quot;&gt; &lt;thead&gt;   &lt;tr&gt;     &lt;th&gt; Types (Expression)&lt;/th&gt;     &lt;th&gt; Effect on other variables&lt;/th&gt;     &lt;th&gt; Resultant Type&lt;/th&gt;   &lt;/tr&gt;&lt;/thead&gt;&lt;tbody&gt;  &lt;tr&gt;    &lt;td&gt; Unsigned integer + Other data types/td&gt;    &lt;td&gt; The other variables gets converted into unsigned integers. &lt;/td&gt;    &lt;td&gt; Unsigned integer &lt;/td&gt; &lt;/tr&gt;  &lt;tr&gt;    &lt;td&gt; Long + Unsigned integer &lt;/td&gt;    &lt;td&gt; Unsigned integers changed to unsigned long. &lt;/td&gt;    &lt;td&gt; Unsigned long &lt;/td&gt; &lt;/tr&gt;  &lt;tr&gt;    &lt;td&gt; Long + Any other data type. &lt;/td&gt;    &lt;td&gt; The other data types are converted into long. &lt;/td&gt;    &lt;td&gt; Long &lt;/td&gt; &lt;/tr&gt;  &lt;tr&gt;    &lt;td&gt; Unsigned long + Other data type. &lt;/td&gt;    &lt;td&gt; The other data types gets converted into long. &lt;/td&gt;    &lt;td&gt; Double &lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;p&gt;&lt;b&gt;For Example,&lt;/b&gt; consider two integer variables &lt;b&gt;a = 2, b = 3;&lt;/b&gt; in general terms one would expect that the solution obtained by performing &lt;b&gt; b / a &lt;/b&gt; would yield &lt;b&gt;1.5&lt;/b&gt;. But, this is not the case, when the same logic is applied in the programs. This is because, as both the variables a and b are declared integers, hence C compilers, considers the result of &lt;b&gt;b / a&lt;/b&gt; as integer, eventually discarding the decimal value. Hence, proper type conversion is necessary to ensure accurate results. &lt;/p&gt;&lt;p&gt; The following are few basic rules which are to be followed while considering type conversion. &lt;/p&gt;&lt;ul&gt;  &lt;li&gt;&lt;b&gt; Unsigned char&lt;/b&gt; and unsigned short cab be converted into unsigned integer.&lt;/li&gt;  &lt;li&gt;&lt;b&gt; Character&lt;/b&gt; and short can be converted in to integer.&lt;/li&gt;  &lt;li&gt;&lt;b&gt; Float&lt;/b&gt; is converted into double.&lt;/li&gt;  &lt;li&gt;&lt;b&gt; int&lt;/b&gt; can be converted in to float.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt;&lt;b&gt; Type Conversion &lt;/b&gt; is necessary because of the following reasons.&lt;/p&gt;&lt;ol&gt; &lt;li&gt;it leads to accurate results and&lt;/li&gt; &lt;li&gt;The code which is properly type converted prevents occurrence of large number of errors.&lt;/li&gt;&lt;/ol&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2018/09/what-do-you-mean-by-type-conversion-in-c-language-or-why-it-is-necessary.html" title="what do you mean by type conversion in C Language or why it is necessary?"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/8386335632152785434/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2018/09/what-do-you-mean-by-type-conversion-in-c-language-or-why-it-is-necessary.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/8386335632152785434'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/8386335632152785434'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2018/09/what-do-you-mean-by-type-conversion-in-c-language-or-why-it-is-necessary.html' title='what do you mean by type conversion in C Language or why it is necessary?'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-3669182974685191489</id><published>2017-02-07T15:05:00.001+05:30</published><updated>2017-09-01T23:27:39.724+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Algorithm"/><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET JQuery"/><category scheme="http://www.blogger.com/atom/ns#" term="HTML5"/><category scheme="http://www.blogger.com/atom/ns#" term="JAVASCRIPT"/><category scheme="http://www.blogger.com/atom/ns#" term="JQUERY"/><title type='text'>Table header checkbox checked all in html by using JQuery</title><content type='html'>&lt;div style=&#39;width:100%; text-align:center;&#39;&gt;&lt;table&gt;&lt;tr&gt;  &lt;th colspan=&#39;1&#39;&gt;    &lt;input id=&#39;chk&#39; type=&#39;checkbox&#39; value=&#39;header&#39;/&gt;  &lt;/th&gt;  &lt;th colspan=&#39;2&#39;&gt;Header CheckBox Demo Click On Checkbox &lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;&lt;input type=&#39;checkbox&#39; value=&#39;1&#39; /&gt;&lt;/td&gt;  &lt;td&gt;John&lt;/td&gt;  &lt;td&gt;Sena&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;&lt;input type=&#39;checkbox&#39; value=&#39;2&#39; /&gt;&lt;/td&gt;  &lt;td&gt;Under&lt;/td&gt;  &lt;td&gt;Taker&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;&lt;input type=&#39;checkbox&#39; value=&#39;3&#39;/&gt;&lt;/td&gt;  &lt;td&gt;Big&lt;/td&gt;  &lt;td&gt;Show&lt;/td&gt;   &lt;/tr&gt;&lt;tr&gt;  &lt;td&gt;&lt;input type=&#39;checkbox&#39; value=&#39;4&#39;/&gt;&lt;/td&gt;  &lt;td&gt;The Great&lt;/td&gt;  &lt;td&gt;Kali&lt;/td&gt;   &lt;/tr&gt;&lt;/table&gt;&lt;/div&gt;&lt;p&gt; In this article i&#39;m going to show you how to select all checkbox when table header checkbox is checked. This article is common for all ASP.NET, ASP.NET MVC, PHP, JAVA,...etc. &lt;/p&gt;&lt;h1&gt;HTML MarkUp Language Code&lt;/h1&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;div style=&amp;#039;width:100%; text-align:center;&amp;#039;&amp;gt;&lt;br /&gt;&amp;lt;table&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;  &amp;lt;th colspan=&amp;#039;1&amp;#039;&amp;gt;&lt;br /&gt;    &amp;lt;input id=&amp;#039;chk&amp;#039; type=&amp;#039;checkbox&amp;#039; value=&amp;#039;header&amp;#039;/&amp;gt;&lt;br /&gt;  &amp;lt;/th&amp;gt;&lt;br /&gt;  &amp;lt;th colspan=&amp;#039;2&amp;#039;&amp;gt;Header CheckBox&lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;&amp;lt;input type=&amp;#039;checkbox&amp;#039; value=&amp;#039;1&amp;#039; /&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;John&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;Sena&amp;lt;/td&amp;gt;  &lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;&amp;lt;input type=&amp;#039;checkbox&amp;#039; value=&amp;#039;2&amp;#039; /&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;Under&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;Taker&amp;lt;/td&amp;gt;  &lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;&amp;lt;input type=&amp;#039;checkbox&amp;#039; value=&amp;#039;3&amp;#039;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;Big&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;Show&amp;lt;/td&amp;gt;  &lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;tr&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;&amp;lt;input type=&amp;#039;checkbox&amp;#039; value=&amp;#039;4&amp;#039;/&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;The Great&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;Kali&amp;lt;/td&amp;gt;  &lt;br /&gt;&amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&amp;lt;/div&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;CSS StyleSheet Code&lt;/h1&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;style&amp;gt;&lt;br /&gt;table{&lt;br /&gt;  border-collapse:collapse;&lt;br /&gt;  width:100%;&lt;br /&gt;}&lt;br /&gt;table th{&lt;br /&gt;  border:1px solid #999;&lt;br /&gt;  background-color:#999;&lt;br /&gt;  color:#fff;&lt;br /&gt;  text-align:center;&lt;br /&gt;  padding-left:10px;&lt;br /&gt;}&lt;br /&gt;table td{&lt;br /&gt;  padding:3px;&lt;br /&gt;}&lt;br /&gt;&amp;lt;/style&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;JQuery Code&lt;/h1&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;script&amp;gt;&lt;br /&gt;$(&quot;#chk&quot;).change(function(){&lt;br /&gt;   if ($(this).is(&#39;:checked&#39;)) {&lt;br /&gt;      $(&quot;input[type=checkbox]&quot;).each(function(index) {&lt;br /&gt;      if($(this).prop(&#39;checked&#39;, true)){&lt;br /&gt;        var value=$(this).val();&lt;br /&gt;       }&lt;br /&gt;      });&lt;br /&gt;   }else{&lt;br /&gt;    $(&quot;input[type=checkbox]&quot;).each(function(index) {&lt;br /&gt;      if($(this).prop(&#39;checked&#39;, false)){&lt;br /&gt;        var value=$(this).val();&lt;br /&gt;       }&lt;br /&gt;      });&lt;br /&gt;   }&lt;br /&gt;});&lt;br /&gt;&amp;lt;/script&amp;gt;&lt;br /&gt;&lt;/pre&gt; &lt;style&gt;table{   border-collapse:collapse;   width:100%; } table th{   border:1px solid #999;   background-color:#999;   color:#fff;   text-align:center;   padding-left:10px; } table td{   padding:3px; } &lt;/style&gt;&lt;script&gt;$(&quot;#chk&quot;).change(function(){    if ($(this).is(&#39;:checked&#39;)) {       $(&quot;input[type=checkbox]&quot;).each(function(index) {       if($(this).prop(&#39;checked&#39;, true)){         var value=$(this).val();        }       });    }else{     $(&quot;input[type=checkbox]&quot;).each(function(index) {       if($(this).prop(&#39;checked&#39;, false)){         var value=$(this).val();        }       });    } }); $(&quot;input[type=checkbox]&quot;).change(function(){  $(&quot;input[type=checkbox]&quot;).each(function(index) {       if($(this).is(&#39;:checked&#39;)){         $(&quot;#chk&quot;).prop(&#39;checked&#39;,true);        }else{        $(&quot;#chk&quot;).prop(&#39;checked&#39;,false);        }        }); }); &lt;/script&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2017/02/jquery-table-header-checkbox-checked-all-in-html.html" title="Table header checkbox checked all in html by using JQuery"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/3669182974685191489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2017/02/jquery-table-header-checkbox-checked-all-in-html.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/3669182974685191489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/3669182974685191489'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2017/02/jquery-table-header-checkbox-checked-all-in-html.html' title='Table header checkbox checked all in html by using JQuery'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-8711577286783306609</id><published>2017-01-30T21:27:00.000+05:30</published><updated>2017-01-30T21:27:23.479+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="WebChat"/><title type='text'>Asp.net Create Simple Chat Application by using C# Coding</title><content type='html'>&lt;p&gt; In this article i&#39;m going to explain one of the method how to create simple web chat application without using &lt;kbd&gt;SignalR&lt;/kbd&gt; &lt;code&gt;DDL&lt;/code&gt; files and any other third parties codes. This article creating with some reference sites.I&#39;m not the author of this project but what ever code its posted its completely modify as per my requirement. &lt;/p&gt;&lt;p&gt;To develop this application i&#39;m going to use &lt;code&gt; Datalist UpdatePanel, Timer Event &lt;/code&gt; and etc.&lt;/p&gt;&lt;h1&gt;Create Tables&lt;/h1&gt;&lt;pre&gt;&lt;br /&gt;CREATE TABLE ChatterTable&lt;br /&gt;(&lt;br /&gt; ID int,&lt;br /&gt; SenderUser varchar(25),&lt;br /&gt; ReceiverUser varchar(25),&lt;br /&gt; Message nvarchar(max),&lt;br /&gt; Date datetime,&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;CREATE TABLE UserTable&lt;br /&gt;(&lt;br /&gt; ID int,&lt;br /&gt; Username varchar(25),&lt;br /&gt; Password varchar(25),&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;Create Login Page&lt;/h1&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;table&amp;gt;&lt;br /&gt; &amp;lt;tr&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;Username : &amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;&amp;lt;asp:TextBox ID=&amp;quot;txtUsername&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt; &amp;lt;/tr&amp;gt;&lt;br /&gt;  &amp;lt;tr&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;Password : &amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;td&amp;gt;&amp;lt;asp:TextBox ID=&amp;quot;txtPassword&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&amp;lt;/td&amp;gt;&lt;br /&gt;  &amp;lt;/tr&amp;gt;&lt;br /&gt;  &amp;lt;tr&amp;gt;&lt;br /&gt;  &amp;lt;td colspan=&amp;quot;2&amp;quot;&amp;gt;&amp;lt;asp:Button ID=&amp;quot;btnLogin&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Login&amp;quot;&amp;gt;&amp;lt;/asp:Button&amp;gt;  &lt;br /&gt;  &amp;lt;/tr&amp;gt;&lt;br /&gt;&amp;lt;/table&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;C# Code : Login Button&lt;/h1&gt;&lt;p&gt; I&#39;m not writing complete code of login just simple using simple code Response.Redirect line &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; //btnLogin Click Event&lt;br /&gt; // if Login successfully then its redirect Chatter.aspx Page&lt;br /&gt;  Response.Redirect(&quot;Chatter.aspx?Username=&quot;+txtUsername.Text.Trim());&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;Create Chatter Page&lt;/h1&gt;&lt;p&gt; In chatter page i&#39;m using &lt;code&gt; Label &lt;/code&gt;, &lt;code&gt; DataList&#39;s &lt;/code&gt; and also &lt;code&gt; UpdatePanel &lt;/code&gt;&lt;/p&gt;&lt;pre&gt;&lt;br /&gt; &amp;lt;body&amp;gt;&lt;br /&gt;&amp;lt;asp:Label ID=&amp;quot;lblUsername&amp;quot; runat=&amp;quot;server&amp;quot; Visible=&amp;quot;false&amp;quot;&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;&amp;lt;asp:DataList ID=&amp;quot;DataListLoadUser&amp;quot; runat=&amp;quot;server&amp;quot; RepeatDirection=&amp;quot;Vertical&amp;quot; Height=&amp;quot;1&amp;quot;&amp;gt;&lt;br /&gt;        &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;                 &amp;lt;asp:LinkButton ID=&amp;quot;lnkUserChatter&amp;quot; ForeColor=&amp;quot;Black&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;#039;&amp;lt;%# Evalundefined&amp;quot;Username&amp;quot;) %&amp;gt;&amp;#039; OnClick=&amp;quot;lnkUserChatter_Click&amp;quot;&amp;gt;&amp;lt;/asp:LinkButton&amp;gt;&lt;br /&gt;       &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;&amp;lt;/asp:DataList&amp;gt;&lt;br /&gt;&amp;lt;asp:UpdatePanel ID=&amp;quot;UpdatePanel1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;     &amp;lt;ContentTemplate&amp;gt;&lt;br /&gt;         &amp;lt;asp:Timer ID=&amp;quot;Timer1&amp;quot; runat=&amp;quot;server&amp;quot; OnTick=&amp;quot;Timer1_Tick&amp;quot; Interval=&amp;quot;1000&amp;quot;&amp;gt;&amp;lt;/asp:Timer&amp;gt;&lt;br /&gt;                 &amp;lt;asp:DataList ID=&amp;quot;DataListChatterPanel&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;        &lt;br /&gt;                &amp;lt;/asp:DataList&amp;gt;&lt;br /&gt;&amp;lt;asp:TextBox ID=&amp;quot;txtMessage&amp;quot; runat=&amp;quot;server&amp;quot; width=&amp;quot;400px&amp;quot; height=&amp;quot;51px&amp;quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;.&lt;br /&gt;&amp;lt;asp:Button ID=&amp;quot;btnSend&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;quot;Send&amp;quot;  OnClick=&amp;quot;btnSend_Click&amp;quot;/&amp;gt; &lt;br /&gt; &amp;lt;/ContentTemplate&amp;gt;&lt;br /&gt; &amp;lt;Trigger&amp;gt;&lt;br /&gt;&amp;lt;asp:AsyncPostBackTrigger Control=&amp;quot;btnSend&amp;quot; Event=&amp;quot;Click&amp;quot; /&amp;gt;&lt;br /&gt; &amp;lt;/Trigger&amp;gt;&lt;br /&gt;&amp;lt;/asp:UpdatePanel&amp;gt;&lt;br /&gt;&lt;br /&gt;&amp;lt;/body&amp;gt; &lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;C# Coding &lt;/h1&gt;&lt;h1&gt;Load UserList in FirstDataList&lt;/h1&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt; protected void Page_Load(----)&lt;br /&gt; {&lt;br /&gt;   if(!IsPostBack)&lt;br /&gt;   {&lt;br /&gt;     LoadUsers();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt; &lt;br /&gt;public void LoadUsers()&lt;br /&gt;{&lt;br /&gt;      string Username = Request.QueryString[&quot;Username&quot;].ToString();           &lt;br /&gt;      con.Open();&lt;br /&gt;      string strQuery = &quot;select DISTINCT Username from UserTable where Username!=&#39;&quot; + Username + &quot;&#39;&quot;;&lt;br /&gt;      SqlCommand cmd = new SqlCommand(strQuery, con);&lt;br /&gt;      SqlDataAdapter da = new SqlDataAdapter(cmd);&lt;br /&gt;      DataSet ds = new DataSet();&lt;br /&gt;      da.Fill(ds);&lt;br /&gt;      DataListLoadUser.DataSource = ds;&lt;br /&gt;      DataListLoadUser.DataBind();&lt;br /&gt;      con.Close();&lt;br /&gt;} &lt;br /&gt;&lt;br /&gt;protected void lnkUserChatter_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;        LinkButton lnkUser = sender as LinkButton;&lt;br /&gt;        string id = ((LinkButton)sender).CommandArgument.ToString();&lt;br /&gt;        Label1.Text = lnkUser.Text; &lt;br /&gt;        LoadChatbox();&lt;br /&gt;}&lt;br /&gt;public void LoadChatbox()&lt;br /&gt;{&lt;br /&gt;        string Username = Request.QueryString[&quot;Username&quot;].ToString();      &lt;br /&gt;        con.Open();&lt;br /&gt;        string strQuery = &quot;select * from ChatterTable where SenderUser =&#39;&quot; + Username + &quot;&#39; and ReceiverUser =&#39;&quot; + Label1.Text + &quot;&#39; or SenderUser =&#39;&quot; + Label1.Text + &quot;&#39; and ReceiverUser =&#39;&quot; + Username + &quot;&#39;&quot;;&lt;br /&gt;        SqlCommand cmd = new SqlCommand(strQuery, con);&lt;br /&gt;        SqlDataAdapterda = new SqlDataAdapter(cmd);&lt;br /&gt;        DataSet ds = new DataSet();&lt;br /&gt;        da.Fill(ds);&lt;br /&gt;        DataListChatterPanel.DataSource = ds;&lt;br /&gt;        DataListChatterPanel.DataBind();&lt;br /&gt;        con.Close();&lt;br /&gt;} &lt;br /&gt;protected void Timer1_Tick(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt;        LoadChatbox();&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;C# Coding for Message Send i.e btnSend&lt;/h1&gt;&lt;pre&gt;&lt;br /&gt;protected void btnSend_Click(object sender, EventArgs e)&lt;br /&gt;{&lt;br /&gt; string date = DateTime.Now.ToString(&quot;MM-dd-yyyy&quot;);&lt;br /&gt; string Username = Request.QueryString[&quot;Username&quot;].ToString();&lt;br /&gt; SqlCommand cmd = new SqlCommand(&quot;Insert into ChaterTable values(&#39;&quot; + Username + &quot;&#39;,&#39;&quot; + Label1.Text + &quot;&#39;,&#39;&quot; + txtMessage.Text + &quot;&#39;,&#39;&quot; + date + &quot;&#39;)&quot;, con);&lt;br /&gt; con.Open();&lt;br /&gt; int i = cmd.ExecuteQuery();&lt;br /&gt; con.Close();&lt;br /&gt; if (i &gt; 0)&lt;br /&gt; {&lt;br /&gt;            txtMessage.Text = &quot;&quot;;&lt;br /&gt; }&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt; </content><link rel="related" href="http://www.dotnetprogramer.in/2017/01/aspnet-create-simple-web-chat-application-by-using-csharp-coding.html" title="Asp.net Create Simple Chat Application by using C# Coding"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/8711577286783306609/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2017/01/aspnet-create-simple-web-chat-application-by-using-csharp-coding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/8711577286783306609'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/8711577286783306609'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2017/01/aspnet-create-simple-web-chat-application-by-using-csharp-coding.html' title='Asp.net Create Simple Chat Application by using C# Coding'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-6375452228520563460</id><published>2017-01-06T21:20:00.001+05:30</published><updated>2017-01-06T21:22:42.023+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="sql server"/><title type='text'>Write a query to delete duplicate records in sql server</title><content type='html'>&lt;table class=&quot;table table-bordered&quot;&gt;&lt;thead style=&#39;background-color:#fafafa; color:#000000; border:1px solid #dddddd;&#39;&gt; &lt;tr&gt;  &lt;th&gt; id &lt;/th&gt;  &lt;th&gt; name &lt;/th&gt;  &lt;th&gt; Age &lt;/th&gt; &lt;/tr&gt;&lt;/thead&gt; &lt;tr&gt;  &lt;td&gt; 1 &lt;/td&gt;  &lt;td&gt; A &lt;/td&gt;  &lt;td&gt; 25 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; 2 &lt;/td&gt;  &lt;td&gt; B &lt;/td&gt;  &lt;td&gt; 26 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; 3 &lt;/td&gt;  &lt;td&gt; C &lt;/td&gt;  &lt;td&gt; 24 &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; 2 &lt;/td&gt;  &lt;td&gt; B &lt;/td&gt;  &lt;td&gt; 26 &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt;&lt;br/&gt;&lt;pre&gt;&lt;br /&gt; Create Table t1&lt;br /&gt; (&lt;br /&gt;   id int,&lt;br /&gt;   name char(10),&lt;br /&gt;   age int&lt;br /&gt; )&lt;br /&gt;&lt;br /&gt; insert into t1&lt;br /&gt;  select 1, &#39;A&#39;, 25 union all&lt;br /&gt;  select 2, &#39;B&#39;, 26 union all&lt;br /&gt;  select 3, &#39;C&#39;, 24 union all&lt;br /&gt;  select 2, &#39;B&#39;, 26&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; First, run the above Group By query to determine how many sets of duplicate &lt;code&gt; Pk &lt;/code&gt; { Primary Key } values exists, and the count of duplicates for each set. &lt;/p&gt;&lt;p&gt; Select the duplicate key values into a holding table. For example :&lt;/p&gt;&lt;pre&gt;&lt;br /&gt; Select id, name, count = count(*) &lt;br /&gt;  into holdkey&lt;br /&gt;  from t1&lt;br /&gt;  Group by id, name &lt;br /&gt;  Having count(*) &gt; 1&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; Select the duplicate rows into a holding table, eliminating duplicates in the process. For example : &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; Select Distinct t1.*&lt;br /&gt;        into holddups&lt;br /&gt;        from t1, holdkey&lt;br /&gt;        Where t1.id = holdkey.id and t1.name = holdkey.name&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; At this point, the holddups table should have unique &lt;code&gt; Pks &lt;/code&gt;, however, this will not be the case if &lt;code&gt; t1 &lt;/code&gt; had duplicate &lt;code&gt; Pks &lt;/code&gt;, yet unique rows (as in the &lt;code&gt; SSN &lt;/code&gt; example above.) Verify that each key in holddups is unique, and that you do not have duplicate keys, yet unique rows. If so, you must stop here and reconcile which of the rows you wish to keep for a given duplicate key value. For example, the query &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; Select id, name, count(*)&lt;br /&gt; From holddups&lt;br /&gt; Group by id, name&lt;br /&gt;&lt;/pre&gt;&lt;p&gt; Delete the duplicate rows from the original table. For example &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; Delete t1&lt;br /&gt; From t1, holdkey&lt;br /&gt; Where t1.id = holdkey.id&lt;br /&gt;&lt;/pre&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2017/01/write-a-query-to-delete-duplicate-records-in-sql-server.html" title="Write a query to delete duplicate records in sql server"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/6375452228520563460/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2017/01/write-a-query-to-delete-duplicate-records-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/6375452228520563460'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/6375452228520563460'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2017/01/write-a-query-to-delete-duplicate-records-in-sql-server.html' title='Write a query to delete duplicate records in sql server'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-8082947525690663918</id><published>2017-01-04T23:36:00.002+05:30</published><updated>2017-01-05T12:04:34.518+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="sql server"/><title type='text'>How to Retrieve non matching records from database in SQL Server</title><content type='html'>&lt;p&gt; In this article i&#39;m going to tell you how to retrieve non matching records from sql server table. To retrieve non matching record i&#39;m using &lt;kbd&gt;Left Join&lt;/kbd&gt; in &lt;code&gt; select query  &lt;/code&gt;&lt;/p&gt;&lt;p&gt;For better understanding purpose i created a image which give more clarity to understand &lt;code&gt; Output Table &lt;/code&gt; is the result of non matching records from 2 tables as i shown in below image &lt;/p&gt;&lt;a href=&quot;https://3.bp.blogspot.com/-hRRT5dEEpxo/WG02OG7pgyI/AAAAAAAACmA/fNP9VxigarkM8KcKPuH1NK4pxCV3u0ekgCLcB/s1600/uncommon%2Bvalue_2.jpg&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://3.bp.blogspot.com/-hRRT5dEEpxo/WG02OG7pgyI/AAAAAAAACmA/fNP9VxigarkM8KcKPuH1NK4pxCV3u0ekgCLcB/s1600/uncommon%2Bvalue_2.jpg&quot; title=&quot;How to Retrieve non matching records from database in SQL Server&quot; alt=&quot;How to Retrieve non matching records from database in SQL Server&quot;/&gt;&lt;/a&gt;&lt;p&gt;In above image we have 2 table i.e &lt;kbd&gt; Technology &lt;/kbd&gt; &amp; &lt;kbd&gt; DuplicateTechnology &lt;/kbd&gt; from left table &lt;code&gt; Technology &lt;/code&gt; i&#39;m getting non matching records from right table &lt;code&gt; DuplicateTechnology &lt;/code&gt;. &lt;/p&gt;&lt;p&gt;First let me create Table&#39;s, Follow the query to create Table and insert records &lt;/p&gt;&lt;h1&gt;Create Technology Table in SQL &lt;/h1&gt;&lt;p&gt; I&#39;m creating this tables in &lt;code&gt; master Database &lt;/code&gt;  &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;CREATE TABLE [dbo].[Technology](&lt;br /&gt; [techid] [int] NULL,&lt;br /&gt; [techname] [varchar](30) NULL&lt;br /&gt;) ON [PRIMARY]&lt;br /&gt;&lt;br /&gt;GO&lt;br /&gt;&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (1, N&#39;Asp.Net&#39;)&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (2, N&#39;C#.Net&#39;)&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (3, N&#39;SQL Server&#39;)&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (4, N&#39;Java&#39;)&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (5, N&#39;JQuery&#39;)&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (6, N&#39;AngularJS&#39;)&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (7, N&#39;Sharepoint&#39;)&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (8, N&#39;Android&#39;)&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (9, N&#39;Linux&#39;)&lt;br /&gt;INSERT [dbo].[Technology] ([techid], [techname]) VALUES (10, N&#39;PHP&#39;)&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;h1&gt;Create DuplicateTechnology Table in SQL &lt;/h1&gt;&lt;p&gt; I&#39;m creating this tables in &lt;code&gt; master Database &lt;/code&gt;  &lt;/p&gt; &lt;pre&gt;&lt;br /&gt; Create Table DuplicateTechnology&lt;br /&gt;(&lt;br /&gt; dtid int,&lt;br /&gt; dtname varchar(30)&lt;br /&gt;)&lt;br /&gt;&lt;br /&gt;insert into DuplicateTechnology values(1, &#39;SQL Server&#39;)&lt;br /&gt;insert into DuplicateTechnology values(2, &#39;JQuery&#39;)&lt;br /&gt;insert into DuplicateTechnology values(3, &#39;Sharepoint&#39;)&lt;br /&gt;insert into DuplicateTechnology values(4, &#39;Android&#39;)&lt;br /&gt;insert into DuplicateTechnology values(5, &#39;PHP&#39;)&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt; &lt;h1&gt;Inner Join : &lt;/h1&gt;&lt;p&gt; &lt;code&gt; Inner Join &lt;/code&gt; is used to retrive matching records from both the tables. &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; select * from Technology t inner join DuplicateTechnology dt on t.techname=dt.dtname&lt;br /&gt;&lt;/pre&gt; &lt;h1&gt;Left Join &lt;/h1&gt;&lt;ul style=&quot;list-style-type:none;&quot;&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; It is used to retrieve all the records from left table and matching records from right table. &lt;/li&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; If they is no matching records in right table then display &lt;code&gt; NULL &lt;/code&gt; value. &lt;/li&gt;&lt;/ul&gt;&lt;pre&gt;&lt;br /&gt; select t.* from Technology t left outer join DuplicateTechnology dt on t.techname=dt.dtname where dt.dtname is Null&lt;br /&gt;&lt;/pre&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2017/01/how-to-retrieve-non-matching-records-from-sql-server-database.html" title="How to Retrieve non matching records from database in SQL Server"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/8082947525690663918/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2017/01/how-to-retrieve-non-matching-records-from-sql-server-database.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/8082947525690663918'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/8082947525690663918'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2017/01/how-to-retrieve-non-matching-records-from-sql-server-database.html' title='How to Retrieve non matching records from database in SQL Server'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://3.bp.blogspot.com/-hRRT5dEEpxo/WG02OG7pgyI/AAAAAAAACmA/fNP9VxigarkM8KcKPuH1NK4pxCV3u0ekgCLcB/s72-c/uncommon%2Bvalue_2.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-3858972112324694276</id><published>2017-01-02T11:57:00.001+05:30</published><updated>2017-01-05T19:38:07.521+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="Interview Question and Answer"/><title type='text'>C#.NET Interview Questions and Answers</title><content type='html'>&lt;h1&gt;What is C#? &lt;/h1&gt;&lt;p&gt;C# is the best language for writing Microsoft .NET applications. C# provides the rapid application development found in Visual Basic with the power of C++. Its syntax is similar to C++ syntax and meets 100% of the requirements of OOPs like the following: &lt;/p&gt;&lt;ul style=&#39;list-style-type:none;&#39;&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Abstraction&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Encapsulation&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Polymorphism&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Inheritance&lt;/li&gt;&lt;/ul&gt;&lt;h1&gt;What is an Object?&lt;/h1&gt;&lt;p&gt;According to MSDN, &quot;a class or struct definition is like a blueprint that specifies what the type can do. An object is basically a block of memory that has been allocated and configured according to the blueprint. A program may create many objects of the same class. Objects are also called instances, and they can be stored in either a named variable or in an array or collection. Client code is the code that uses these variables to call the methods and access the public properties of the object. In an object-oriented language such as C#, a typical program consists of multiple objects interacting dynamically&quot;. &lt;/p&gt;&lt;p&gt;Objects helps us to access the member of a class or struct either they can be fields, methods or properties, by using the dot. To know more about object read the following links: &lt;/p&gt;&lt;ul style=&#39;list-style-type:none;&#39;&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; &lt;a href=&quot;http://www.dotnetprogramer.in/p/oops-interview-question-answer-p-1.html&quot; title=&quot;Oops Interview Question and Answers&quot;&gt;All Object-Oriented Programming Interview Questions and Answers&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h1&gt;What is Managed or Unmanaged Code?&lt;/h1&gt;&lt;h3&gt;Managed Code&lt;/h3&gt;&lt;p&gt;“The code, which is developed in .NET framework is known as managed code. This code is directly executed by CLR with the help of managed code execution. Any language that is written in .NET Framework is managed code”. &lt;/p&gt;&lt;h3&gt;Unmanaged Code&lt;/h3&gt;&lt;p&gt;The code, which is developed outside .NET framework is known as unmanaged code. &lt;br/&gt;“Applications that do not run under the control of the CLR are said to be unmanaged, and certain languages such as C++ can be used to write such applications, which, for example, access low - level functions of the operating system. Background compatibility with the code of VB, ASP and COM are examples of unmanaged code”. &lt;br/&gt;Unmanaged code can be unmanaged source code and unmanaged compile code. Unmanaged code is executed with the help of wrapper classes. &lt;br/&gt;Wrapper classes are of two types: &lt;/p&gt;&lt;ul style=&#39;list-style-type:none;&#39;&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; CCW (COM Callable Wrapper).&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; RCW (Runtime Callable Wrapper).&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Managed code and unmanaged code in .NET&lt;/li&gt;&lt;/ul&gt; &lt;h1&gt;What is Boxing and Unboxing?&lt;/h1&gt;&lt;p&gt; Boxing and Unboxing both are used for type conversion but have some difference:&lt;/p&gt;&lt;h3&gt;Boxing:&lt;/h3&gt;&lt;p&gt; Boxing is the process of converting a value type data type to the object or to any interface data type which is implemented by this value type. When the CLR boxes a value means when CLR is converting a value type to Object Type, it wraps the value inside a System.Object and stores it on the heap area in application domain. &lt;/p&gt;&lt;h3&gt;Example:&lt;/h3&gt;&lt;pre&gt;&lt;br /&gt;public void Function1()&lt;br /&gt; {&lt;br /&gt;   int i = 111;&lt;br /&gt;   object o  = i;&lt;br /&gt;   Console.WriteLine(o);&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;h3&gt;Unboxing:&lt;/h3&gt;&lt;p&gt;Unboxing is also a process which is used to extract the value type from the object or any implemented interface type. Boxing may be done implicitly, but unboxing have to be explicit by code. &lt;/p&gt;&lt;h3&gt;Example:&lt;/h3&gt;&lt;pre&gt;&lt;br /&gt;public void Function1()&lt;br /&gt; {&lt;br /&gt;   int o = 111;&lt;br /&gt;   object i  = (int)o;&lt;br /&gt;   Console.WriteLine(i);&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;The concept of boxing and unboxing underlines the C# unified view of the type system in which a value of any type can be treated as an object.&lt;/p&gt;&lt;h1&gt;What is the difference between a struct and a class in C#?&lt;/h1&gt;&lt;ul style=&#39;list-style-type:none;&#39;&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; &lt;a href=&quot;http://www.dotnetprogramer.in/2015/06/what-is-structure-in-csharp-in-software-it-technologies.html&quot; title=&quot;What is Structure, and Difference Between struct and class&quot;&gt;Difference Between Struct and Class&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h1&gt; What is the difference between Interface and Abstract Class?&lt;/h1&gt;&lt;p&gt;&lt;ul style=&#39;list-style-type:none;&#39;&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; &lt;a href=&quot;http://www.dotnetprogramer.in/p/oops-interview-question-answer-p-5.html&quot; title=&quot;Difference Between Interface and Abstract Class&quot;&gt;Difference Between Interface and Abstract Class&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/p&gt;&lt;h1&gt;What is Enum in C#&lt;/h1&gt;&lt;ul style=&#39;list-style-type:none;&#39;&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; An enumeration is a collection of constants. That means you can create your own set of named constants by using enumerations.&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Each constant will have a name with an integer value.&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Syntax for Enumeration Declaration: &lt;/li&gt;&lt;pre&gt;&lt;br /&gt; public enum enumname&lt;br /&gt; {&lt;br /&gt;   Constant1 = value1, Constant2 = value2, Constant3 = value3 &lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Syntax for usage&lt;/li&gt;&lt;pre&gt;  enumname.constantname  &lt;/pre&gt;&lt;/ul&gt;&lt;h1&gt;Can “this” be used within a static method?&lt;/h1&gt;&lt;p&gt;We can&#39;t use this in static method because keyword &#39;this&#39; returns a reference to the current instance of the class containing it. Static methods (or any static member) do not belong to a particular instance. They exist without creating an instance of the class and call with the name of a class not by instance so we can’t use this keyword in the body of static Methods, but in case of Extension Methods we can use it the functions parameters. Let’s have a look on “this” keyword. &lt;/p&gt;&lt;p&gt;The &quot;this&quot; keyword is a special type of reference variable that is implicitly defined within each constructor and non-static method as a first parameter of the type class in which it is defined. For example, consider the following class written in C#. &lt;/p&gt;&lt;h1&gt;Define Property in C#.net?&lt;/h1&gt;&lt;p&gt;Properties are members that provide a flexible mechanism to read, write or compute the values of private fields, in other words by the property we can access private fields. In other words we can say that a property is a return type function/method with one parameter or without a parameter. These are always public data members. It uses methods to access and assign values to private fields called accessors. &lt;/p&gt;&lt;p&gt;Now question is what are accessors? &lt;/p&gt;&lt;p&gt;The get and set portions or blocks of a property are called accessors. These are useful to restrict the accessibility of a property, the set accessor specifies that we can assign a value to a private field in a property and without the set accessor property it is like a read-only field. By the get accessor we can access the value of the private field, in other words it returns a single value. A Get accessor specifies that we can access the value of a field publically. &lt;/p&gt;&lt;p&gt; We have the three types of properties &lt;/p&gt;&lt;ul style=&#39;list-style-type:none;&#39;&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Read/Write.&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; ReadOnly.&lt;/li&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; WriteOnly&lt;/li&gt;&lt;/ul&gt;&lt;h1&gt;What is the difference between dispose and finalize methods in c#?&lt;/h1&gt;&lt;ul style=&#39;list-style-type:none;&#39;&gt;&lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; &lt;a href=&quot;http://www.dotnetprogramer.in/p/csharp-interview-question-answer.html&quot;&gt; Difference Between Finalize and Dispose Method&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;h1&gt;What is IEnumerable&lt;&gt; in c#?&lt;/h1&gt;&lt;p&gt;IEnumerable is the parent interface for all non-generic collections in System.Collections namespace like ArrayList, HastTable etc. that can be enumerated. For the generic version of this interface as IEnumerable&lt;T&gt; which a parent interface of all generic collections class in System.Collections.Generic namespace like List&lt;&gt; and more. &lt;/p&gt;&lt;p&gt;In System.Collections.Generic.IEnumerable&lt;T&gt; have only a single method which is GetEnumerator() that returns an IEnumerator. IEnumerator provides the power to iterate through the collection by exposing a Current property and Move Next and Reset methods, if we doesn’t have this interface as a parent so we can’t use iteration by foreach loop or can’t use that class object in our LINQ query. &lt;/p&gt;&lt;img src=&quot;http://csharpcorner.mindcrackerinc.netdna-cdn.com/UploadFile/8ef97c/top-50-C-Sharp-net-interview-questions-and-answers/Images/image14.png&quot; class=&quot;img-responsive&quot; /&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2017/01/4-plus-years-cshap-net-interview-questions-and-answers.html" title="C#.NET Interview Questions and Answers"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/3858972112324694276/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2017/01/4-plus-years-cshap-net-interview-questions-and-answers.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/3858972112324694276'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/3858972112324694276'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2017/01/4-plus-years-cshap-net-interview-questions-and-answers.html' title='C#.NET Interview Questions and Answers'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-7846990483833105941</id><published>2016-12-22T19:17:00.002+05:30</published><updated>2016-12-22T19:17:56.612+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="ListBox"/><title type='text'>ListBox show data from database in asp.net</title><content type='html'>&lt;p&gt; In this article i&#39;m going to show you &lt;code&gt; how to bind data from database into listbox control in asp.net &lt;/code&gt;&lt;/p&gt;&lt;h1&gt;HTML Markup Language - Add ListBox&lt;/h1&gt;&lt;p&gt; ListBox control allows single or multiple item selection. To enable multiple item selection, set the &lt;code&gt; SelectionMode &lt;/code&gt; property to Multiple.  &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;%@ Page Language=&amp;quot;C#&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; CodeFile=&amp;quot;Default.aspx.cs&amp;quot; Inherits=&amp;quot;_Default&amp;quot; %&amp;gt; &lt;br /&gt;&amp;lt;!DOCTYPE html PUBLIC &amp;quot;-//W3C//DTD XHTML 1.0 Transitional//EN&amp;quot; &amp;quot;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&amp;quot;&amp;gt; &lt;br /&gt;&amp;lt;html xmlns=&amp;quot;http://www.w3.org/1999/xhtml&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;head runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;title&amp;gt;&amp;lt;/title&amp;gt;&lt;br /&gt;&amp;lt;/head&amp;gt;&lt;br /&gt;&amp;lt;body&amp;gt;&lt;br /&gt;    &amp;lt;form id=&amp;quot;form1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&lt;br /&gt;    &amp;lt;div&amp;gt;&lt;br /&gt;        &amp;lt;asp:ListBox ID=&amp;quot;ListBox1&amp;quot; runat=&amp;quot;server&amp;quot;&amp;gt;&amp;lt;/asp:ListBox&amp;gt;&lt;br /&gt;    &amp;lt;/div&amp;gt;  &lt;br /&gt;    &amp;lt;/form&amp;gt;&lt;br /&gt;&amp;lt;/body&amp;gt;&lt;br /&gt;&amp;lt;/html&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;C# Coding : &lt;/h1&gt;&lt;h3&gt;C# Coding : Namespace &lt;/h3&gt;&lt;p&gt; Adding Namespace which help to Bind data from database to application i.e &lt;code&gt; SqlConnection &lt;/code&gt;, &lt;code&gt; SqlCommand &lt;/code&gt;, &lt;code&gt; SqlDataAdapter &lt;/code&gt; and &lt;code&gt; DataSet &lt;/code&gt;. &lt;/p&gt;&lt;pre&gt;&lt;br /&gt; using System.Data;&lt;br /&gt; using System.Data.SqlClient;&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;C# Coding : BindCountryListBox&lt;/h1&gt;&lt;p&gt; &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;protected void Page_Load(object sender, EventArgs e)&lt;br /&gt; {&lt;br /&gt;  if (!IsPostBack)&lt;br /&gt;   {&lt;br /&gt;     BindCountryListBox();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private void BindCountryListBox()&lt;br /&gt; {&lt;br /&gt;   SqlConnection conn = new SqlConnection(&quot;Data Source=.; Database=master; User ID=sa; Password=12345;&quot;);&lt;br /&gt;   SqlDataAdapter da = new SqlDataAdapter(&quot;select countryid, countryname from CountryTable&quot;, conn);&lt;br /&gt;   DataSet ds = new DataSet();&lt;br /&gt;   da.Fill(ds);&lt;br /&gt;   ListBox1.DataSource = ds;&lt;br /&gt;   ListBox1.DataTextField = &quot;countryid&quot;;&lt;br /&gt;   ListBox1.DataValueField = &quot;countryname&quot;;&lt;br /&gt;   ListBox1.DataBind(); &lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/12/display-data-into-listbox-from-database-in-asp.net.html" title="ListBox show data from database in asp.net"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/7846990483833105941/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/12/display-data-into-listbox-from-database-in-asp.net.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/7846990483833105941'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/7846990483833105941'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/12/display-data-into-listbox-from-database-in-asp.net.html' title='ListBox show data from database in asp.net'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-2936882650800637004</id><published>2016-12-21T11:56:00.002+05:30</published><updated>2017-01-05T19:54:08.037+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="ASPNET GRIDVIEW"/><category scheme="http://www.blogger.com/atom/ns#" term="Gridview"/><title type='text'>Gridview RowDeleting Event in Asp.Net by using C# </title><content type='html'>&lt;p&gt; In this article i&#39;m going to explain about &lt;code&gt; &quot;How to Delete record from Gridview Row in Asp.net by using c# coding&quot; &lt;/code&gt; with an example, you can find source code of this example below. &lt;/p&gt;&lt;h1&gt;HTML Markup Language - Add Gridview to WebForm1.aspx&lt;/h1&gt;&lt;p&gt; I&#39;m adding &lt;code&gt; Gridview &lt;/code&gt; control to my webpage and binding student data from database into gridview control by using an method called &lt;code&gt; BindGridviewStudent &lt;/code&gt;. &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;asp:GridView ID=&amp;quot;GridView1&amp;quot; CssClass = &amp;quot;Grid&amp;quot; runat=&amp;quot;server&amp;quot; OnRowDeleting=&amp;quot;OnRowDeleting&amp;quot; AutoGenerateColumns = &amp;quot;false&amp;quot;&amp;gt;&lt;br /&gt;&amp;lt;Columns&amp;gt;&lt;br /&gt; &amp;lt;asp:TemplateField HeaderText=&amp;quot;StudentID&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;   &amp;lt;asp:Label ID=&amp;quot;lblSID&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;#039;&amp;lt;%# Bindundefined&amp;quot;studentid&amp;quot;) %&amp;gt;&amp;#039;&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;  &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;  &amp;lt;ItemStyle Width=&amp;quot;100px&amp;quot; /&amp;gt;&lt;br /&gt; &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt; &amp;lt;asp:TemplateField HeaderText=&amp;quot;Name&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;   &amp;lt;asp:Label ID=&amp;quot;lblSName&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;#039;&amp;lt;%# Bindundefined&amp;quot;studentname&amp;quot;) %&amp;gt;&amp;#039;&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;   &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;   &amp;lt;ItemStyle Width=&amp;quot;100px&amp;quot; /&amp;gt;&lt;br /&gt; &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt; &amp;lt;asp:TemplateField HeaderText=&amp;quot;Contact No&amp;quot;&amp;gt;&lt;br /&gt;  &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;   &amp;lt;asp:Label ID=&amp;quot;lblSPhone&amp;quot; runat=&amp;quot;server&amp;quot; Text=&amp;#039;&amp;lt;%# Bindundefined&amp;quot;studentphone&amp;quot;) %&amp;gt;&amp;#039;&amp;gt;&amp;lt;/asp:Label&amp;gt;&lt;br /&gt;  &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;  &amp;lt;ItemStyle Width=&amp;quot;100px&amp;quot; /&amp;gt;&lt;br /&gt; &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt; &amp;lt;asp:TemplateField HeaderText=&amp;quot;Contact No&amp;quot;&amp;gt;&lt;br /&gt;   &amp;lt;ItemTemplate&amp;gt;&lt;br /&gt;    &amp;lt;asp:LinkButton ID=&amp;quot;lnkDelete&amp;quot; runat=&amp;quot;server&amp;quot; CommandName=&amp;quot;delete&amp;quot;&amp;gt; Delete &amp;lt;/asp:LinkButton&amp;gt;&lt;br /&gt;   &amp;lt;/ItemTemplate&amp;gt;&lt;br /&gt;   &amp;lt;ItemStyle Width=&amp;quot;100px&amp;quot; /&amp;gt;&lt;br /&gt; &amp;lt;/asp:TemplateField&amp;gt;&lt;br /&gt;&amp;lt;/Columns&amp;gt;&lt;br /&gt;&amp;lt;/asp:GridView&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt;C# Coding &lt;/h1&gt;&lt;h3&gt;C# Coding : Adding Namespace&lt;/h3&gt;&lt;p&gt; i&#39;m adding this namespace, to create database connection and also retrieved data from database to bind gridview control by using this object {i.e &lt;code&gt; SqlConnection &lt;/code&gt;, &lt;code&gt; SqlCommand &lt;/code&gt; and &lt;code&gt; SqlDataAdapter &lt;/code&gt; and also &lt;code&gt; DataSet &lt;/code&gt;. &lt;/p&gt;&lt;h1&gt;C# Coding : BindGridviewStudent Method&lt;/h1&gt;&lt;p&gt; In this section i&#39;m creating private method to bind data from database to gridview. &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt; public void Page_Load(-----)&lt;br /&gt; {&lt;br /&gt;   if(!IsPostBack)&lt;br /&gt;   {&lt;br /&gt;     BindGridviewStudent();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; private void BindGridviewStudent()&lt;br /&gt; {&lt;br /&gt;  SqlConnection con = new SqlConnection(&quot;Data Source=.; DataBase=master; User ID=sa; Password=12345;&quot;);&lt;br /&gt;  SqlDataAdapter da = new SqlDataAdapter(&quot;Select * from Student&quot;, con);&lt;br /&gt;  DataSet ds = new DataSet();&lt;br /&gt;  da.fill(ds);&lt;br /&gt;  GridView1.DataSource = ds;&lt;br /&gt;  GridView1.DataBind();&lt;br /&gt; }&lt;br /&gt;&lt;br /&gt; //Add here Gridview RowDeleteing Event&lt;br /&gt; protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)&lt;br /&gt; {&lt;br /&gt;  GridViewRow gdRow = (GridViewRow)GridView1.Rows[e.RowIndex];&lt;br /&gt;  Label lblID = (Label)gdRow.FindControl(&quot;lblSID&quot;);&lt;br /&gt;  SqlConnection con = new SqlConnection(&quot;Data Source=.; DataBase=master; User ID=sa; Password=12345;&quot;);&lt;br /&gt;  SqlCommand cmd = new SqlCommand(&quot;delete from Student where studentid=&#39;&quot;+lblID.Text+&quot;&#39;&quot;, con);&lt;br /&gt;  con.Open();&lt;br /&gt;  int i = cmd.ExecuteNonQuery();&lt;br /&gt;  con.Close();&lt;br /&gt;  if (i &gt; 0)&lt;br /&gt;   {&lt;br /&gt;     BindGridviewStudent();&lt;br /&gt;   }&lt;br /&gt; }&lt;br /&gt;&lt;/pre&gt;&lt;h3&gt; Note : &lt;/h3&gt;&lt;p&gt;&lt;code&gt;   GridViewRow gdRow = (GridViewRow)GridView1.Rows[e.RowIndex]; &lt;/code&gt; this line give index of row, i.e nothing but which row we are going to delete that row index value given based on that value i&#39;m retrieving &lt;code&gt; StudentID &lt;/code&gt; value from gridview and passing that studenid value to database to delete that record from database. &lt;/p&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/12/aspnet-gridview-row-deleting-event-by-using-csharp-coding.html" title="Gridview RowDeleting Event in Asp.Net by using C# "/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/2936882650800637004/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/12/aspnet-gridview-row-deleting-event-by-using-csharp-coding.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/2936882650800637004'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/2936882650800637004'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/12/aspnet-gridview-row-deleting-event-by-using-csharp-coding.html' title='Gridview RowDeleting Event in Asp.Net by using C# '/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-4716427836979898243</id><published>2016-11-21T12:30:00.000+05:30</published><updated>2017-01-05T19:55:17.720+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.NET"/><category scheme="http://www.blogger.com/atom/ns#" term="XML"/><title type='text'>How to Create SiteMap Automatically in Asp.net</title><content type='html'>&lt;p&gt;In this article I&#39;m going to show you how to create sitemap automatically. This sitemap is used to create SEO friendly page after fetching the data from database. This Sitemap help for crawling the pages in search engine for that you need to create this Sitemap and map to those search engines. &lt;/p&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-ueieIISVYU8/WDKXsNmNKRI/AAAAAAAAClY/3Ar2Zm0QTzUrhYm9vKdkHMahpWfSaxW2wCLcB/s1600/sitemap.jpg&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-ueieIISVYU8/WDKXsNmNKRI/AAAAAAAAClY/3Ar2Zm0QTzUrhYm9vKdkHMahpWfSaxW2wCLcB/s1600/sitemap.jpg&quot; title=&quot;How to Create SiteMap Automatically in Asp.net&quot; alt=&quot;How to Create SiteMap Automatically in Asp.net&quot; /&gt;&lt;/a&gt;&lt;p&gt;The sitemap is a great way to tell the search engines about all your web pages. For that first we need to create &lt;b&gt;robots.txt&lt;/b&gt; file in your project main folder &lt;/p&gt;&lt;p&gt; Now add one web page to the project and change the names of the page &lt;code&gt;&lt;b&gt; Default.aspx &lt;/b&gt;&lt;/code&gt; to &lt;code&gt;&lt;b&gt; sitemap.aspx &lt;/b&gt;&lt;/code&gt; and after adding page then delete all &lt;code&gt;&lt;b&gt; html code &lt;/b&gt;&lt;/code&gt;in this page &lt;/p&gt;&lt;p&gt;Replace this html code from deleted html code in sitemap.aspx &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt; &amp;lt;%@ Page Language=&amp;quot;C#&amp;quot; AutoEventWireup=&amp;quot;true&amp;quot; &lt;br /&gt; CodeFile=&amp;quot;sitemap.aspx.cs&amp;quot; Inherits=&amp;quot;sitemap&amp;quot; &lt;br /&gt;  ContentType =&amp;quot;text/xml&amp;quot; %&amp;gt;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;p&gt;Because this is an XML sitemap, we want to send the XML directly to the browser. So, even though the page is an .aspx extension, when its sent to the browser we will make sure it thinks its XML by adding ContentType =&quot;text/xml&quot; in the page directive. &lt;/p&gt;&lt;p&gt;Now goto the .aspx.cs page and add the below code : &lt;/p&gt;&lt;h1&gt;C# Coding : Namespace&lt;/h1&gt;&lt;p&gt; The Namespace which i&#39;m using in my project are &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt; using System.XML;&lt;br /&gt; using System.Text;&lt;br /&gt; using System.Data;&lt;br /&gt; using System.Data.SqlClient;&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;h1&gt; C# Coding : Page Load&lt;/h1&gt;&lt;p&gt;  &lt;/p&gt;&lt;pre&gt;&lt;br /&gt;&lt;br /&gt; protected void Page_Load(object sender, EventArgs e)&lt;br /&gt;        {&lt;br /&gt;            try&lt;br /&gt;            {&lt;br /&gt;                SqlConnection cn = new SqlConnection(&quot;Data Source=.; Database=Databasename; User ID=; Password=;&quot;);&lt;br /&gt;                string mydomain = &quot;http://www.example.com&quot;; //ex : http://www.example.com&lt;br /&gt;&lt;br /&gt;                string strSql = &quot;select post_id, post_title from webpost&quot;;&lt;br /&gt;                SqlDataAdapter dacontent = new SqlDataAdapter(strSql, cn);&lt;br /&gt;                DataSet dscontent = new DataSet();&lt;br /&gt;                dacontent.Fill(dscontent, &quot;SiteMap&quot;); //here we fill all the products into dataset&lt;br /&gt;&lt;br /&gt;                //Now we are going to create XML file using XMLTextWriter&lt;br /&gt;&lt;br /&gt;                XmlTextWriter writer = new XmlTextWriter(Response.OutputStream, Encoding.UTF8);&lt;br /&gt;                writer.WriteStartDocument();&lt;br /&gt;                writer.WriteStartElement(&quot;urlset&quot;, &quot;http://www.sitemaps.org/schemas/sitemap/0.9&quot;);&lt;br /&gt;&lt;br /&gt;                writer.WriteStartElement(&quot;url&quot;);&lt;br /&gt;&lt;br /&gt;                writer.WriteElementString(&quot;loc&quot;, &quot;http://www.example.com&quot;);&lt;br /&gt;                writer.WriteElementString(&quot;priority&quot;, &quot;0.5&quot;);&lt;br /&gt;                writer.WriteEndElement();&lt;br /&gt;&lt;br /&gt;                //Now we loop for creating the XML node for all products&lt;br /&gt;                if (dscontent.Tables[0].Rows.Count &gt; 0)&lt;br /&gt;                {&lt;br /&gt;                    DataRow dtr;&lt;br /&gt;                    int i = 0;&lt;br /&gt;                    while (i &lt; dscontent.Tables[0].Rows.Count)&lt;br /&gt;                    {&lt;br /&gt;                        dtr = dscontent.Tables[0].Rows[i];&lt;br /&gt;&lt;br /&gt;                        //Creating the  element&lt;br /&gt;                        writer.WriteStartElement(&quot;url&quot;);&lt;br /&gt;&lt;br /&gt;                        writer.WriteElementString(&quot;loc&quot;, mydomain + &quot;/&quot; + dtr[&quot;post_title &quot;].ToString());&lt;br /&gt;                        writer.WriteElementString(&quot;priority&quot;, &quot;0.5&quot;);&lt;br /&gt;&lt;br /&gt;                        //End URL&lt;br /&gt;                        writer.WriteEndElement();&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;                        i++;&lt;br /&gt;                    }&lt;br /&gt;                }&lt;br /&gt;                writer.WriteEndDocument();&lt;br /&gt;                writer.Close();&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;            catch (Exception ex)&lt;br /&gt;            {&lt;br /&gt;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/how-to-create-sitemap-automatically-in-aspnet.html" title="How to Create SiteMap Automatically in Asp.net"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/4716427836979898243/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/how-to-create-sitemap-automatically-in-aspnet.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/4716427836979898243'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/4716427836979898243'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/how-to-create-sitemap-automatically-in-aspnet.html' title='How to Create SiteMap Automatically in Asp.net'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://2.bp.blogspot.com/-ueieIISVYU8/WDKXsNmNKRI/AAAAAAAAClY/3Ar2Zm0QTzUrhYm9vKdkHMahpWfSaxW2wCLcB/s72-c/sitemap.jpg" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-7058415253713543634</id><published>2016-11-16T19:51:00.002+05:30</published><updated>2017-01-05T19:57:54.650+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>What is an Expression in C Language</title><content type='html'>&lt;h1&gt;Expression : &lt;/h1&gt;&lt;p&gt; An expression consists of a single entity such as a constant, a variable, an array element or a reference to a function or can be a combination of such entities joined together using one or more operators i.e. an expression is a single constant or a single variable or combination of constants, variables and operators. &lt;/p&gt;&lt;p&gt; An expression can also represent logical condition, that is either true or false, which can be represented using integer values like 1 and 0 respectively. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;&lt;b&gt;Exampless : Valid expressions of C are as follows.&lt;/b&gt;&lt;br/&gt; 1. c = a + b * d; &lt;br/&gt; 2. x &lt;= y; &lt;br/&gt; 3. x = y; &lt;br/&gt; 4. x == y; &lt;br/&gt; 5. x += y; &lt;/div&gt;&lt;p&gt; As seen from the above examples, each valid expression in C is terminated using a semicolon(;) also each expression reveals its own meaning.&lt;/p&gt;&lt;p&gt;The descriptions of above mentioned expressions are as follows : &lt;/p&gt;&lt;ul&gt; &lt;li&gt;The expression 1 &lt;corresponds to homogeneous expression, consisting of four operands (c, a, b, d) three operators (=, +, *) and a semicolon (;). The assignment operator (=) indicates, that the result of the expression is assigned to a variable C. The execution of homogeneous expressions follow &lt;b&gt;BODMAS&lt;/b&gt; principle.&lt;/li&gt; &lt;li&gt; The expression 2 is a conditional expression, where a specified condition is matched between the operands x and y i.e,. In expression 2, the condition whether x is less than or equal to (&lt;=) y is determined. &lt;/li&gt; &lt;li&gt; The expression 3 is a assignment expression, where the value of y is assigned to a variable x. &lt;/li&gt;   &lt;li&gt; The expression 4 is also a conditional expression, where a condition is verified i.e., whether the value of x is equal to the value of y is determined.&lt;/li&gt; &lt;li&gt; The expression 5 corresponds to addition as well as assignment expression. the expression x += y is equivalent to x = x + y, whether the values of x and y are added and the result is assigned to x.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; Apart from the above mentioned expressions, C supports certain complex expressions like, &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; a = 3 + 5 % 3 - 6 / 2 * 4 % 2 ; &lt;br/&gt; b = 3 + 5 % 3 - 6 / 2 * 4 % 2 + ++x - y++ + (2 &amp; 3) - ( 3 &amp;&amp; 2); &lt;br/&gt; c = 3 + 5 % 3 - 5 / 2 * 4 % 2 + ++x - y++ + 2 &amp; 3 - 3 &amp;&amp; 2; &lt;br/&gt; d = ++x - x-- + y++ + x++ - --y + ++y; &lt;br/&gt; e = 2 + 3 - 4 * 2 &amp;&amp; 4 &lt;&lt; 2 % 2 &lt;= 2 == 3 &amp; 4 &gt; !5 || 6; &lt;br/&gt; f = 2 &gt; 3 ? 2 : 3 + 2 * 3 == 3 * 4 ? 1 : 0 * 2 &lt; 3 ? 2 : 3 - 4; &lt;/div&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/what-is-an-expression-in-and-what-kind-of-information-is-represented-by-an-expression.html" title="What is an Expression in C Language"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/7058415253713543634/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/what-is-an-expression-in-and-what-kind-of-information-is-represented-by-an-expression.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/7058415253713543634'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/7058415253713543634'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/what-is-an-expression-in-and-what-kind-of-information-is-represented-by-an-expression.html' title='What is an Expression in C Language'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-7048036195054738696</id><published>2016-11-16T15:48:00.001+05:30</published><updated>2017-01-05T19:59:17.931+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Working of Binary Operators in C Language</title><content type='html'>&lt;h1&gt;Binary Operators : &lt;/h1&gt;&lt;p&gt;  Binary operators are the most basic and common operators. These operators require two operands and an operator between them.&lt;/p&gt;&lt;p&gt; The following table shows the binary operators and their meanings :&lt;/p&gt;&lt;table class=&quot;table table-bordered&quot;&gt; &lt;tr&gt;  &lt;th&gt;&lt;b&gt;Binary Operator&lt;/b&gt;&lt;/th&gt;  &lt;th&gt;&lt;b&gt;Meaning&lt;/b&gt;&lt;/th&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; + &lt;/td&gt;  &lt;td&gt; Addition of two numbers &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; - &lt;/td&gt;  &lt;td&gt; Subtraction of two numbers &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; * &lt;/td&gt;  &lt;td&gt; Multiplication of two numbers &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; / &lt;/td&gt;  &lt;td&gt; Division of a number by another &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; % &lt;/td&gt;  &lt;td&gt; Modulo of a number by another &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt;&lt;p&gt; In division the operands can be of integer or floating point type. If any one of the operands is floating point type, the result will be of floating-point type. If both the operands are integers the result will be integer. &lt;/p&gt;&lt;p&gt;   However, the modulo operation cannot be done with floating point type. Both the operands for the modulo operator must be integer type. It returns the remainder as an integer type. The result of modulo division will take the sign of the first operand. &lt;/p&gt;&lt;p&gt; The multiplicative expressions that include the multiplication, division and modulo operators have the highest priority among binary operators. The additive expressions that include the addition and subtraction operators have lower priority than multiplicative expressions. Therefore, they are evaluated after the multiplicative expressions. &lt;/p&gt;&lt;h1&gt;Strings in C Language :&lt;/h1&gt;&lt;p&gt; A String is a sequence of characters that is treated as a data item.&lt;/p&gt;&lt;p&gt; The group of characters, digits, and symbols enclosed within quotation marks is called as &quot;string&quot;. The sting is always declared as a character array. To manipulate text such as words and sentences normally strings are used. Every string is terminated with &#39;\0&#39; (NULL) character. The NULL character is a byte with all bits at logic zero. Hence, its decimal value is zero. &lt;/p&gt;&lt;pre&gt; Example : char name[] = {&#39;I&#39;, &#39;N&#39;, &#39;D&#39;, &#39;I&#39;, &#39;A&#39;, &#39;\0&#39; }; &lt;/pre&gt;&lt;b&gt;Character Strings&lt;/b&gt; are often used to build meaningful and readable programs. &lt;p&gt; The common operations performed on character strings include : &lt;/p&gt;&lt;ul&gt; &lt;li&gt; Reading and writing String&lt;/li&gt; &lt;li&gt; Combining String together&lt;/li&gt; &lt;li&gt; Copying one String to another String&lt;/li&gt; &lt;li&gt; Comparing Strings for equality&lt;/li&gt; &lt;li&gt; Extracting a portion of a String&lt;/li&gt;&lt;/ul&gt;&lt;h1&gt;C Token : &lt;/h1&gt;&lt;p&gt; In passage of text, individual words and punctuation marks are called tokens. Similarly, in a C program the smallest individual units are known as &lt;b&gt;C Tokens.&lt;/b&gt; C programs are written using these tokens and the syntax of the language. C has six types of token as shown in the figure. &lt;/p&gt;&lt;a href=&quot;https://2.bp.blogspot.com/-3tSlpPVLW6w/WCw3VrukP7I/AAAAAAAAClI/2LGt8QqzpDAhjY4UdZPcMy-IHrQ1e7LLgCLcB/s1600/c%2Btoken.png&quot; imageanchor=&quot;1&quot; &gt;&lt;img border=&quot;0&quot; src=&quot;https://2.bp.blogspot.com/-3tSlpPVLW6w/WCw3VrukP7I/AAAAAAAAClI/2LGt8QqzpDAhjY4UdZPcMy-IHrQ1e7LLgCLcB/s1600/c%2Btoken.png&quot; title=&quot;Working of Binary Operators in C Language&quot; alt=&quot;Working of Binary Operators in C Language&quot; /&gt;&lt;/a&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-the-working-of-binary-operators.html" title="Working of Binary Operators in C Language"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/7048036195054738696/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-working-of-binary-operators.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/7048036195054738696'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/7048036195054738696'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-working-of-binary-operators.html' title='Working of Binary Operators in C Language'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://2.bp.blogspot.com/-3tSlpPVLW6w/WCw3VrukP7I/AAAAAAAAClI/2LGt8QqzpDAhjY4UdZPcMy-IHrQ1e7LLgCLcB/s72-c/c%2Btoken.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-1291379927582470321</id><published>2016-11-16T15:39:00.001+05:30</published><updated>2017-01-05T20:02:28.313+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Unary Operators in C Languages</title><content type='html'>&lt;p&gt;Unary Operators include &lt;/p&gt;&lt;ul style=&quot;list-style-type:none;&quot;&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Increment (++) and Decrement (--) Operators &lt;/li&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Minus (-) Operator &lt;/li&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Address (&amp;) and Size SizeOf Operators &lt;/li&gt;&lt;/ul&gt;&lt;p&gt; These operators are &lt;b&gt;Unary Operators&lt;/b&gt; because they act on only one operand. &lt;br/&gt; &lt;b&gt;Unary Operators&lt;/b&gt; will be given the highest priority over binary and ternary operators. While evaluating expressions unary operators follow right to left associativity. &lt;table class=&quot;table table-bordered&quot;&gt; &lt;tr&gt;  &lt;th&gt;&lt;b&gt;Operator&lt;/b&gt; &lt;/th&gt;  &lt;th&gt;&lt;b&gt;Description (or) Action&lt;/b&gt; &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; ++ &lt;/td&gt;  &lt;td&gt; Increment Operator &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; -- &lt;/td&gt;  &lt;td&gt; Decrement Operator &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; - &lt;/td&gt;  &lt;td&gt; Minus Operator &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; &amp; &lt;/td&gt;  &lt;td&gt; Address Operator &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; SizeOf &lt;/td&gt;  &lt;td&gt; Sizeof Operator &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt;&lt;/p&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Increment (++) and Decrement (--) Operators : &lt;/h1&gt;&lt;p&gt; The operator ++ adds one to its operand, wheras the operator -- subtracts one from its operand.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; x = x + 1; can be written as x++ &lt;br/&gt; x = x - 1; can be written as x-- &lt;/div&gt;&lt;p&gt; if ++ and -- are used as suffix to the variable name, then the post increment of decrement operations take place.&lt;/p&gt;&lt;p&gt; If ++ and -- are used as prefix to the variable name, then pre increment/decrement operations take place.&lt;/li&gt;&lt;div class=&quot;well well-sm&quot;&gt;Example : 1 &lt;br/&gt; x = 20; &lt;br/&gt; y = 10; &lt;br/&gt; z = x * y++; &lt;/div&gt;&lt;p&gt; Here, the current value of y is used for product and after performing the operation, the value of y is incremented. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; Result is, z = 20 * 10 = 200; &lt;br/&gt;&lt;br/&gt;Example : 2  &lt;br/&gt; x = 20; &lt;br/&gt; y = 10; &lt;br/&gt; z = x * ++y; &lt;/div&gt;&lt;p&gt;Here, the value of y is incremented first and then used for the product.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; Result is, z = 20 * 11 = 220 &lt;/div&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Minus (-) Operator &lt;/h1&gt;&lt;p&gt; Minus Operator is used to indicate or change the algebraic sign of a value. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;Example : 1 &lt;br/&gt; int x = -50; &lt;br/&gt; int y = -x; &lt;/div&gt;&lt;p&gt;First assignment, assigns the value -50 to x and the second assignment assigns the value of 50 to y through x. &lt;br/&gt;The - sign used in this way is called unary oerpator, because it takes only one operand.&lt;/p&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Address (&amp;) and Size SizeOf Operators&lt;/h1&gt;&lt;p&gt; The sizeof operator gives the bytes occupied by a variable. The number of bytes occupied varies from variable to variable.&lt;/p&gt;&lt;p&gt; The &amp; (address) operator prints the address of the variable in the memory. &lt;/p&gt;&lt;h3&gt;Program : This program explains the Sizeof and Address Operators &lt;/h3&gt;&lt;pre&gt;&lt;br /&gt; #include&lt;stdio.h&gt;&lt;br /&gt; main()&lt;br /&gt;  {&lt;br /&gt;    int x = 2;&lt;br /&gt;    float y = 2;&lt;br /&gt;    printf(&quot;sizeof(x)=%d bytes \n&quot;, sizeof(x));&lt;br /&gt;    printf(&quot;sizeof(y)=%d bytes \n&quot;, sizeof(y));&lt;br /&gt;    printf(&quot;address of x=%u and y = %u&quot;, &amp;x, &amp;y);&lt;br /&gt;  }&lt;br /&gt;&lt;/pre&gt;&lt;b&gt;Output : &lt;/b&gt;&lt;div class=&quot;well well-sm&quot;&gt; sizeof (x) = 2 bytes &lt;br/&gt; sizeof (y) = 4 bytes &lt;br/&gt; Address of x = 4066 and y = 25096 &lt;/div&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-the-working-of-unary-operators-with-examples.html" title="Unary Operators in C Languages"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/1291379927582470321/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-working-of-unary-operators-with-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/1291379927582470321'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/1291379927582470321'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-working-of-unary-operators-with-examples.html' title='Unary Operators in C Languages'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-5356032308026280378</id><published>2016-11-16T14:26:00.000+05:30</published><updated>2017-01-05T20:04:04.929+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Special Operators in C Language</title><content type='html'>&lt;h1&gt;Special Operators : &lt;/h1&gt;&lt;p&gt; C Supprots the following three types of special operators. &lt;/p&gt;&lt;ul style=&quot;list-style-type:none;&quot;&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Comma Operator&lt;/li&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; SizeOf Operator&lt;/li&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Member Selection Operator&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; comma is a binary operator whereas sizeof is a unary operator. &lt;br/&gt; comma operators generally used in loops.&lt;br/&gt; A sizeof operator is normally used to determine the lengths of arrays and structures. &lt;/p&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Comma Operator : &lt;/h1&gt;&lt;p&gt; The comma operator (,) can be used to link the related expressions together. A comma-linked list of expressions are evaluated left to right and the value of right most expression is the value of the combined expression. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; Syntax : exp m = (exp 1, exp 2, .... exp n) &lt;/div&gt;&lt;p&gt; The comma operator has the lowest priority among all the operators available in C. &lt;br/&gt; Comma operator follows right to left associativity. &lt;br/&gt; Comma operator is a binary operator. &lt;br/&gt; &lt;b&gt;Example : value = (x = 10, y = 5, x + y );&lt;/b&gt;&lt;/p&gt;&lt;p&gt; First assigns the value 10 to x, then assigns 5 to y, and finally assigns 15(i.e, 10 + 5) to value. Since comma operator has the lowest precedence of all operators, the pair of parentheses are necessary. &lt;/p&gt;&lt;b&gt;Applications :&lt;/b&gt;&lt;div class=&quot;well well-sm&quot;&gt;&amp;nbsp;&amp;nbsp; In for loops :  for(n = 1, m = 10, n &lt;= m; n++, m++) &lt;br/&gt;&amp;nbsp;&amp;nbsp; In while loops :  while( c = getchar(),  != &#39;10&#39;) &lt;br/&gt;&amp;nbsp;&amp;nbsp; Exchanging values : t = x, x = y, y = t;  &lt;/div&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; SizeOf Operator : &lt;/h1&gt;&lt;p&gt; The SizeOf is a compile time operator and when used with an operand, it returns the number of bytes that the operand occupies. The operand may be a variable, a contant or a data type qualifier. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; Syntax : sizeOf(opeand) &lt;/div&gt;&lt;p&gt;&lt;b&gt;Examples : &lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;1. y = sizeOf(int); Here value of y will be 2 bytes. &lt;br/&gt;2. z = sizeOf(a); Here value of z depends on data type of a  &lt;/div&gt;&lt;p&gt; A sizeOf operator is normally used to determine the lengths of arrays and structures, when their sizes are not known to the programmer. It is also used to allocate memory space dynamically to variables during execution of a program. &lt;/p&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Member Selection Operator : &lt;/h1&gt;&lt;p&gt; These operators are used to access members of structures and unions. They are represented by dot(.) and arrow(&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;). &lt;/p&gt;&lt;p&gt;&lt;b&gt;Examples : &lt;/b&gt;&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;1. var.member1; /* when var is a structure variable */ &lt;br/&gt;2. var &lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; member2; /* when var is a pointer to structure variable */ &lt;/div&gt;&lt;nav aria-label=&quot;...&quot;&gt;  &lt;ul class=&quot;pager&quot;&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-the-conditional-operator-in-c-language-with-examples.html&quot;&gt;Previous&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-the-operators-in-c-languages-with-examples.html&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-about-special-operators-in-c-language-with-examples.html" title="Special Operators in C Language"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/5356032308026280378/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-about-special-operators-in-c-language-with-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5356032308026280378'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5356032308026280378'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-about-special-operators-in-c-language-with-examples.html' title='Special Operators in C Language'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-5273657273338314017</id><published>2016-11-16T11:40:00.004+05:30</published><updated>2017-01-05T20:07:30.038+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Conditional Operator or Ternary Operator in C Language</title><content type='html'>&lt;h1&gt;Conditional Operator : &lt;/h1&gt;  &lt;p&gt;It is also known as a &lt;b&gt;Ternary Operator&lt;/b&gt; because it acts on three operands. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; Syntax : exp1 ? exp2 ? exp3; &lt;br/&gt; where exp1, exp2 and exp3 are expressions.&lt;/div&gt;&lt;h1&gt;Operation of Conditional Operator : &lt;/h1&gt;&lt;p&gt; The value of exp1 is evaluated first. If it is true, value of exp2 is evaluated otherwise exp3 is evaluated. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;&lt;b&gt; Examples : &lt;/b&gt;&lt;br/&gt; 1. int a = 5, b = 10, c = 15; &lt;br/&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; y = (a &gt; b)? b : c; &lt;/div&gt;&lt;p&gt;The expression a &gt; b is evaluated, since it is false the value of c will be assigned to y. So the value of y will be 15.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; 2. int a = 5, b = 10, c = 15; &lt;br/&gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; y = (a &lt; b)? b : c; &lt;/div&gt;&lt;p&gt;The expression a &lt; b is evaluated, since it is true the value of b will be assigned to y. So, the value of y will be 10.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; 3. Greatest of three numbers using conditional operators. &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; x = (a &gt; b &amp;&amp; a &gt; c)? a : (b &gt; c? b : c); &lt;/div&gt;&lt;p&gt; Here greatest of three numbers is calculated and stored in the variable x. If more than one conditional operators is there in an expression the &lt;br/&gt;&lt;b&gt;Conditional Operators&lt;/b&gt; will be evaluated from right to left. &lt;br/&gt;&lt;b&gt;Conditional Operators &lt;/b&gt;follow right to left associativity. &lt;/p&gt;  &lt;h1&gt;Bitwise Operator : &lt;/h1&gt;&lt;p&gt;C has distinction of supporting special operators known as bitwise operators for manipulation of data at bit level. These operators are used for testing the bits, or shifting them to right or left.&lt;/p&gt;&lt;table class=&quot;table table-bordered&quot;&gt; &lt;tr&gt;  &lt;th&gt;&lt;b&gt;Operator&lt;/b&gt; &lt;/th&gt;  &lt;th&gt;&lt;b&gt;Meaning&lt;/b&gt; &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; &amp;&amp; &lt;/td&gt;  &lt;td&gt; Bitwise AND &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; | &lt;/td&gt;  &lt;td&gt; Bitwise OR &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; ^ &lt;/td&gt;  &lt;td&gt; Bitwise Exclusive - OR &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; &lt;&lt; &lt;/td&gt;  &lt;td&gt; Shift left &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; &gt;&gt; &lt;/td&gt;  &lt;td&gt; Shift right &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; ~ &lt;/td&gt;  &lt;td&gt; One&#39;s complement &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt;&lt;p&gt; When bitwise operators are used with variables, they are internally converted to binary numbers and then bitwise operators are applied on individual bits. Bitwise operators perform manipulation on bits stored in memory. These operators work with char and int data types. They cnnot be used with floating point numbers. &lt;/p&gt;&lt;p&gt; The operators &amp;, |, &lt;&lt;, &gt;&gt;, ^ are binary operators whereas the operator ~ is a unary operator. &lt;br/&gt; Relative precedence of Bitwise operators is as follow : &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; Highest &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ~ &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &gt;&gt;, &lt;&lt; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^ &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; || &lt;br/&gt; Lowest &lt;/div&gt;&lt;p&gt; When equal priority operators are there in an expression, the operators will be evaluated from left to right i.e thy follow left to right associativity.&lt;br/&gt; Bitwise NOT i.e one&#39;s complement (~) follows right to left associativity.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;Examples 1 : &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If a = 4, b = 6, find the values of all bitwise operators. &lt;br/&gt;  &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The equivalent binary value of a is 0 0 0 0 0 1 0 0 &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The equivalent binary value of b is 0 0 0 0 0 1 1 0 &lt;br/&gt;&amp;nbsp;&amp;nbsp; a. a &amp; b is 0 0 0 0 0 1 0 0 &lt;br/&gt;&amp;nbsp;&amp;nbsp; The value of c = a &amp; b is 4 &lt;br/&gt;&amp;nbsp;&amp;nbsp; b. a | b is 0 0 0 0 0 1 1 0 &lt;br/&gt;&amp;nbsp;&amp;nbsp; The value if c = a | b is 6 &lt;br/&gt;&amp;nbsp;&amp;nbsp; c. a ^ b is 0 0 0 0 0 0 1 0 &lt;br/&gt;&amp;nbsp;&amp;nbsp; The value of c = a^b is 2 &lt;br/&gt;&amp;nbsp;&amp;nbsp; d. c = a &lt;&lt; 2. &#39;&lt;&lt;&#39; left shifts the binary bits of a by two positions.&lt;br/&gt;&amp;nbsp;&amp;nbsp; c = 0 0 0 1 0 0 0 0 &lt;br/&gt;&amp;nbsp;&amp;nbsp; The value of c = a &lt;&lt; b is 16. &lt;br/&gt;&amp;nbsp;&amp;nbsp; e. c = a &gt;&gt; 2. &#39;&gt;&gt;&#39; right shifts the binary bits of a by two positions. &lt;br/&gt;&amp;nbsp;&amp;nbsp; c = 0 0 0 0 0 0 0 1 &lt;br/&gt;&amp;nbsp;&amp;nbsp; The value of c = a &gt;&gt; b is 1. &lt;br/&gt;&amp;nbsp;&amp;nbsp; f. c = ~a. The value of c is the 1&#39;s complement of a. &lt;br/&gt;&amp;nbsp;&amp;nbsp; The value of c = ~a is -5.&lt;br/&gt;&lt;/div&gt;&lt;br/&gt;&lt;div class=&quot;well well-sm&quot;&gt;Examples 2 : &lt;br/&gt;&amp;nbsp;&amp;nbsp; -3 &amp; 4 = 4 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5 &amp; -8 = 0 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -15 &amp; -29 = -31 &lt;br/&gt;&amp;nbsp;&amp;nbsp; -7 | 4 = -3 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12 |-6 = -2 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -24|-9 = -1 &lt;br/&gt;&amp;nbsp;&amp;nbsp; -5^6 = -3 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9^-14 = -5 &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -4^-9 = 11 &lt;br/&gt;&amp;nbsp;&amp;nbsp; -15&lt;&lt;6=-960,&amp;nbsp;-23&lt;&lt;4 = -368,&amp;nbsp;-14&gt;&gt;9=1-,&amp;nbsp;-5&gt;&gt;1=-3&lt;br/&gt; &lt;br/&gt;&amp;nbsp;&amp;nbsp; ~(-18) = 17, &amp;nbsp; ~7=-8,&amp;nbsp; ~(-3)=2,&amp;nbsp;~(-27)=26 &lt;/div&gt;&lt;nav aria-label=&quot;...&quot;&gt;  &lt;ul class=&quot;pager&quot;&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-increment-and-decrement-operators-in-c-language-with-examples.html&quot;&gt;Previous&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-about-special-operators-in-c-language-with-examples.html&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-the-conditional-operator-in-c-language-with-examples.html" title="Conditional Operator or Ternary Operator in C Language"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/5273657273338314017/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-conditional-operator-in-c-language-with-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5273657273338314017'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5273657273338314017'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-conditional-operator-in-c-language-with-examples.html' title='Conditional Operator or Ternary Operator in C Language'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-2048160209694279322</id><published>2016-11-16T11:40:00.003+05:30</published><updated>2017-01-05T20:09:08.455+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Increment and Decrement Operators in C Language</title><content type='html'>&lt;h1&gt;Increment and Decrement Operators : &lt;/h1&gt;&lt;p&gt; Increment Operator is represented by ++. It increment the operand by 1.&lt;br/&gt; Decrement Operator is represented by --. It decrements the operand by 1.  &lt;/p&gt;&lt;table class=&quot;table table-bordered&quot;&gt; &lt;tr&gt;  &lt;th&gt; &lt;b&gt;Operator&lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt;Meaning&lt;/b&gt; &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; a++ &lt;/td&gt;  &lt;td&gt; post-increment &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; ++a &lt;/td&gt;  &lt;td&gt; pre-increment &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; a-- &lt;/td&gt;  &lt;td&gt; post-decrement &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; --a &lt;/td&gt;  &lt;td&gt; pre-decrement &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt;&lt;div class=&quot;well well-sm&quot;&gt;&lt;b&gt;Note : &lt;/b&gt;&lt;br/&gt;Increment and Decrement operators can not be applied on floating points. &lt;/div&gt;&lt;p&gt;Rules for ++ and -- operators : &lt;/p&gt;&lt;ul&gt; &lt;li&gt; Increment and Decrement operators are unary operators and require variables as operands.&lt;/li&gt; &lt;li&gt; When postfix ++ (or --) is used with a variable in an expression, the expression is evaluated first using the original value of the variable and then the variable is incremented (or decremented) by one.&lt;/li&gt; &lt;li&gt; When prefix ++ (or --) is used with a variable in an expression, the variable is incremented (or decremented) first and then the expression is evaluated using the new value of the variable.&lt;/li&gt; &lt;li&gt;The precedence and associativity of ++ and -- operators are the same as those of unary + and unary -.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; We use the increment and decrement statements in for and while loops extensively. These two operators are unary operators, they operate on only one operand. &lt;br/&gt; They follow right to left associativity.&lt;/p&gt;&lt;b&gt;Examples : &lt;/b&gt;&lt;div class=&quot;well well-sm&quot;&gt; 1. post - increment : &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int a = 8; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = a++; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The value of y will be 8. &lt;br/&gt; 2. pre - increment : &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int a = 8; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = ++a; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The value of y will be 9. &lt;br/&gt; 3. post - decrement : &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int a = 5; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = a--; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The value of y will be 5. &lt;br/&gt; 4. pre - decrement : &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; int a = 5; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; y = --a; &lt;br/&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The value of y will be 4. &lt;/div&gt;&lt;nav aria-label=&quot;...&quot;&gt;  &lt;ul class=&quot;pager&quot;&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-the-working-of-assignment-operator-in-c-language-with-exmaples.html&quot;&gt;Previous&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-the-conditional-operator-in-c-language-with-examples.html&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-increment-and-decrement-operators-in-c-language-with-examples.html" title="Increment and Decrement Operators in C Language"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/2048160209694279322/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-increment-and-decrement-operators-in-c-language-with-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/2048160209694279322'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/2048160209694279322'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-increment-and-decrement-operators-in-c-language-with-examples.html' title='Increment and Decrement Operators in C Language'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-5515797205301592721</id><published>2016-11-15T23:29:00.006+05:30</published><updated>2017-01-05T20:11:13.559+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Assignment Operators in C Languages</title><content type='html'>&lt;p&gt;&lt;b&gt;Assignment Operators : &lt;/b&gt;Assignment operators are used to assign the results of an expression to a variable. In addition to usual assignment operator, C has a set of shorthand assignment operators.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; syntax for assignment operator : var = exp &lt;br/&gt; syntax for shorthand assignment operator : var op = exp &lt;/div&gt;&lt;p&gt;where var is variable, exp is an expression and op is a C binary arithmetic operator. The operator op = is known as the shorthand assignment operators.&lt;/p&gt;&lt;p&gt;the assignment t statement : &lt;b&gt;var = var op exp&lt;/b&gt; is equivalent to : &lt;b&gt;var op = exp&lt;/b&gt;&lt;/p&gt;&lt;table class=&quot;table table-bordered&quot;&gt; &lt;tr&gt;  &lt;th&gt; &lt;b&gt;Assignment Operator&lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt;Shorthand Assignment&lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt;Meaning of both operators&lt;/b&gt; &lt;/th&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; a = a + 1 &lt;/td&gt;  &lt;td&gt; a += 1 &lt;/td&gt;  &lt;td&gt; adds 1 to a and assigns the value to a &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; a = a - 1 &lt;/td&gt;  &lt;td&gt; a -= 1 &lt;/td&gt;  &lt;td&gt; subtracts 1 from a and assigns the value to a &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; a = a/(b + 5) &lt;/td&gt;  &lt;td&gt; a/= (b+5) &lt;/td&gt;  &lt;td&gt; divides a by b+5 and assigns the value to a &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;  &lt;td&gt; a = a * (b+5) &lt;/td&gt;  &lt;td&gt; a *= (b+5) &lt;/td&gt;  &lt;td&gt; multiplies a by b+5 and assigns the value to a &lt;/td&gt; &lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Invalid assignment statements : &lt;b&gt;2 = 5 + 3; 2 = b;&lt;/b&gt; &lt;br/&gt;Assignment operator is a binary operator. &lt;br/&gt;Assignment operator follows right to left associativity. &lt;/p&gt;&lt;p&gt;The use of shorthand assignment operators has three advantages : &lt;/p&gt;&lt;ol&gt; &lt;li&gt;What appears on the left-hand side need not be repeated and therefore it becomes easier to write.&lt;/li&gt; &lt;li&gt;The statement is more concise and easier to read.&lt;/li&gt; &lt;li&gt;The statement is more efficient.&lt;/li&gt;&lt;/ol&gt;&lt;nav aria-label=&quot;...&quot;&gt;  &lt;ul class=&quot;pager&quot;&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/logical-operators-in-c-languages.html&quot;&gt;Previous&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-increment-and-decrement-operators-in-c-language-with-examples.html&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-the-working-of-assignment-operator-in-c-language-with-exmaples.html" title="Assignment Operators in C Languages"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/5515797205301592721/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-working-of-assignment-operator-in-c-language-with-exmaples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5515797205301592721'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5515797205301592721'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-working-of-assignment-operator-in-c-language-with-exmaples.html' title='Assignment Operators in C Languages'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-5063583515945402137</id><published>2016-11-15T23:29:00.005+05:30</published><updated>2017-01-05T20:13:04.010+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Logical Operators in C Languages</title><content type='html'>&lt;p&gt;&lt;b&gt;Logical Operators : &lt;/b&gt; C has the following three logical operators&lt;/p&gt;&lt;ul style=&quot;list-style-type:none;&quot;&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;b&gt; Logical AND - &amp;&amp; &lt;/b&gt;&lt;/li&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;b&gt; Logical OR - || &lt;/b&gt;&lt;/li&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;&lt;b&gt; Logical NOT - ! &lt;/b&gt;&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; The logical operators &lt;b&gt;&amp;&amp;&lt;/b&gt; and &lt;b&gt;||&lt;/b&gt; are used, to test more than one condition and make decisions.&lt;/p&gt;&lt;p&gt;An expression which combines two or more relational expressions is termed as a logical expression or a compound relational expression. Like the simple relational expression, a logical expression also yields value of one or zero. True is taken as 1 and false is taken as 0.&lt;/p&gt;&lt;p&gt;   The zero value is taken as false, while the non-zero value is taken as true. &lt;b&gt; Logical AND, Logical OR &lt;/b&gt; are binary operators whereas &lt;b&gt;Logical NOT&lt;/b&gt; is a unary operator. &lt;/p&gt;&lt;p&gt; The operator &lt;b&gt;!&lt;/b&gt; will be given the highest priority over &lt;b&gt;&amp;&amp; and || &lt;/b&gt;.&lt;/p&gt;&lt;p&gt; When equal priority operators are there in an expression, the operators will be evaluated from left to right i.e they follow left to right associativity. &lt;b&gt;Logical NOT(!)&lt;/b&gt; follows right to left associativity. &lt;/p&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Logical AND : &lt;/h1&gt;&lt;p&gt; The result of logical &lt;b&gt;AND&lt;/b&gt; expression will be true only, when both the relational expressions are true.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; Syntax : exp1 &amp;&amp; exp2 &lt;/div&gt;&lt;div class=&quot;well well-sm&quot;&gt;Examples :   &lt;ol&gt;  &lt;li&gt; If a = 10, b = 5, c = 15 and i = (a &gt; b) &amp;&amp; (b &lt; c); &lt;br/&gt; The value of i in this expression will be 1.&lt;/li&gt;  &lt;li&gt; If a = 10, b = 5, c = 15 and i = (a &lt; b) &amp;&amp; (b &lt; c); &lt;br/&gt; The value of i in this expression will be 0.&lt;/li&gt; &lt;/ol&gt;&lt;/div&gt;&lt;h4&gt;Truth table for Logical AND : &lt;/h4&gt;&lt;table class=&quot;table table-bordered&quot;&gt;  &lt;tr&gt;  &lt;th&gt; &lt;b&gt;exp1&lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt;exp2&lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt;exp1 &amp;&amp; exp2&lt;/b&gt; &lt;/th&gt; &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; T &lt;/td&gt;   &lt;td&gt; T &lt;/td&gt;      &lt;td&gt; T &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; T &lt;/td&gt;   &lt;td&gt; F &lt;/td&gt;   &lt;td&gt; F &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; F &lt;/td&gt;   &lt;td&gt; T &lt;/td&gt;   &lt;td&gt; F &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; F &lt;/td&gt;   &lt;td&gt; F &lt;/td&gt;   &lt;td&gt; F &lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt; &lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Logical OR : &lt;/h1&gt;&lt;p&gt; The result of logical &lt;b&gt;OR&lt;/b&gt; expression will be false only, when both the relational expressions are false.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; Syntax : exp1 || exp2 &lt;/div&gt;&lt;div class=&quot;well well-sm&quot;&gt;Examples :   &lt;ol&gt;  &lt;li&gt; If a = 10, b = 5, c = 15 and i = (a &lt; b) || (b &lt; c); &lt;br/&gt; The value of i in this expression will be 1.&lt;/li&gt;  &lt;li&gt; If a = 10, b = 5, c = 15 and i = (a &lt; b) &amp;&amp; (b &gt; c); &lt;br/&gt; The value of i in this expression will be 0.&lt;/li&gt; &lt;/ol&gt;&lt;/div&gt;&lt;h4&gt;Truth table for Logical AND : &lt;/h4&gt;&lt;table class=&quot;table table-bordered&quot;&gt;  &lt;tr&gt;  &lt;th&gt; &lt;b&gt;exp1&lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt;exp2&lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt;exp1 &amp;&amp; exp2&lt;/b&gt; &lt;/th&gt; &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; F &lt;/td&gt;   &lt;td&gt; F &lt;/td&gt;      &lt;td&gt; F &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; F &lt;/td&gt;   &lt;td&gt; T &lt;/td&gt;   &lt;td&gt; T &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; T &lt;/td&gt;   &lt;td&gt; F &lt;/td&gt;   &lt;td&gt; T &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; T &lt;/td&gt;   &lt;td&gt; T &lt;/td&gt;   &lt;td&gt; T &lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt; &lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Logical NOT : &lt;/h1&gt;&lt;p&gt; The result of logical &lt;b&gt;NOT&lt;/b&gt; expression will be true, if the expression false and vice versa.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; Syntax : ! exp1  &lt;/div&gt;&lt;div class=&quot;well well-sm&quot;&gt;Examples :   &lt;ol&gt;  &lt;li&gt; If a = 10, b = 5, c = 15 and i = !((a &lt; b) &amp;&amp; (b &lt; c)); &lt;br/&gt; The value of i in this expression will be 1.&lt;/li&gt;  &lt;li&gt; If x = 20 and i = !(x == 20) &lt;br/&gt; The value of i will be 0, because x == 20 is true and !i = 0.&lt;/li&gt; &lt;/ol&gt;&lt;/div&gt;&lt;h4&gt;Truth table for Logical AND : &lt;/h4&gt;&lt;table class=&quot;table table-bordered&quot;&gt;  &lt;tr&gt;  &lt;th&gt; &lt;b&gt;Exp&lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt;!exp&lt;/b&gt; &lt;/th&gt; &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; T &lt;/td&gt;   &lt;td&gt; F &lt;/td&gt;     &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; F &lt;/td&gt;   &lt;td&gt; T &lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;&lt;b&gt;De Morgan&#39;s Rule : &lt;/b&gt;&lt;div class=&quot;well well-sm&quot;&gt; i.  !(x &amp;&amp; y) -&gt; !x || !y &lt;br/&gt; ii. !(x || y) -&gt; !x &amp;&amp; !y &lt;/div&gt;&lt;div class=&quot;well well-sm&quot;&gt; Examples : &lt;br/&gt;1. !(2 &amp;&amp; 0) = 1 = !2 || !0 &lt;br/&gt;2. !(2 || -7) = 0 = !2 &amp;&amp; !(-7) &lt;/div&gt;&lt;p&gt;Relative precedence of the relational and logical operators is as follows : &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;Highest  ! &lt;br/&gt; &gt; &gt;= &lt; &lt;= &lt;br/&gt; == != &lt;br/&gt; &amp;&amp; &lt;br/&gt; || Lowest &lt;/div&gt;&lt;b&gt;Example : The value is !(3 &amp;&amp; 4 &gt;= 7 || 6) is 1&lt;/b&gt;&lt;nav aria-label=&quot;...&quot;&gt;  &lt;ul class=&quot;pager&quot;&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/what-are-the-relational-operators-in-c-languages-and-explain-with-examples.html&quot;&gt;Previous&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-the-working-of-assignment-operator-in-c-language-with-exmaples.html&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/what-are-the-relational-operators-in-c-languages-and-explain-with-examples.html" title="Logical Operators in C Languages"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/5063583515945402137/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/logical-operators-in-c-languages.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5063583515945402137'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5063583515945402137'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/logical-operators-in-c-languages.html' title='Logical Operators in C Languages'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-5839862175256609756</id><published>2016-11-15T23:29:00.004+05:30</published><updated>2017-01-05T20:14:03.541+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Relational Operators in C Languages</title><content type='html'>&lt;p&gt;&lt;b&gt;Relational Operators : &lt;/b&gt; Relational operators are used in &lt;b&gt;Boolean conditions&lt;/b&gt; or  expressions, that return either true or false.&lt;/p&gt;&lt;p&gt;The relational operators returns zero values or non-zero values. The zero values is taken as false, while the non-zero value is taken as true.&lt;/p&gt;&lt;p&gt;A simple relational expression contains only one relational operator and takes the following form : ,/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; ae - 1 relational operator ae - 2 &lt;/div&gt;&lt;p&gt;&lt;b&gt;ae - 1&lt;/b&gt; and &lt;b&gt;ae - 2&lt;/b&gt; are arithmetic expressions, which may be simple constants, variables or combination of them and arithmetic operators. &lt;br/&gt;C supports six Relational operators and are as follows : &lt;/p&gt;&lt;table class=&quot;table table-bordered&quot;&gt;  &lt;tr&gt;  &lt;th&gt; &lt;b&gt;Operator&lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt;Meaning&lt;/b&gt; &lt;/th&gt; &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; &lt; &lt;/td&gt;   &lt;td&gt; less than &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; &lt;= &lt;/td&gt;   &lt;td&gt; less than or equal to &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; &gt; &lt;/td&gt;   &lt;td&gt; greater than &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; &gt;= &lt;/td&gt;   &lt;td&gt; greater than or equal to &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; == &lt;/td&gt;   &lt;td&gt; is equal to &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; != &lt;/td&gt;   &lt;td&gt; is not equal to &lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;&lt;p&gt;Relational operators are used to compare two quantities.,/p&gt;&lt;p&gt;Relational operators are binary operators, because they act on two operands.&lt;/p&gt;&lt;p&gt;The operators &lt;, &lt;=, &gt;, &gt;= will be given the highest priority over ==, !=&lt;/p&gt;&lt;p&gt;when equal priority operators are there in an expression, the operators will be evaluated from left to right i.e they follow left to right associativity.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;&lt;b&gt;Example&#39;s : &lt;/b&gt;&lt;br/&gt; 4.5 &lt;= 10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;       true &lt;br/&gt; 4.5 &lt; -10&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;       false&lt;br/&gt; -35 &gt;= 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;        false&lt;br/&gt; 10 &lt; 7 + 5&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;true &lt;br/&gt; (10+5) == (3*5)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; true &lt;/div&gt;&lt;p&gt;a + b == c + d true, only if the sum of values of a and b is equal to the sum of values of c and d.&lt;/p&gt;&lt;p&gt; When arithmetic expressions are used on either side of a relational operator, then the arithmetic expressions will be evaluated first and then the results will be compared. That is, arithmetic operators have a higher priority over relational operators. &lt;/p&gt;&lt;p&gt; Relational expressions are used in decision statements such as if and while to decide the course of action of a running program.&lt;/p&gt;&lt;h1&gt;Relational Operator Complements : &lt;/h1&gt;&lt;p&gt; Among the six relational operators, each one is a complement of another operator.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; &gt;   is complement of &lt;= &lt;br/&gt; &lt;   is complement of &gt;= &lt;br/&gt; ==  is complement of != &lt;/div&gt;&lt;p&gt; We can simplify an expression involving the not and the relational operators using the complements as shown below : &lt;/p&gt;&lt;table class=&quot;table table-bordered&quot;&gt;  &lt;tr&gt;  &lt;th&gt; &lt;b&gt; Actual one &lt;/b&gt; &lt;/th&gt;  &lt;th&gt; &lt;b&gt; Simplified one &lt;/b&gt; &lt;/th&gt; &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; !(x + y) &lt;/td&gt;   &lt;td&gt; x &gt;= y &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; !(x &gt; y) &lt;/td&gt;   &lt;td&gt; x &lt;= y &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; !(x != y) &lt;/td&gt;   &lt;td&gt; x == y &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; !(x &lt;= y) &lt;/td&gt;   &lt;td&gt; x &gt; y &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; !(x &gt;= y) &lt;/td&gt;   &lt;td&gt; x &lt; y &lt;/td&gt;  &lt;/tr&gt;  &lt;tr&gt;   &lt;td&gt; !(x == y) &lt;/td&gt;   &lt;td&gt; x != y &lt;/td&gt;  &lt;/tr&gt;&lt;/table&gt;&lt;br/&gt;&lt;nav aria-label=&quot;...&quot;&gt;  &lt;ul class=&quot;pager&quot;&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-the-operators-in-c-languages-with-examples.html&quot;&gt;Previous&lt;/a&gt;&lt;/li&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/logical-operators-in-c-languages.html&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/what-are-the-relational-operators-in-c-languages-and-explain-with-examples.html" title="Relational Operators in C Languages"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/5839862175256609756/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/what-are-the-relational-operators-in-c-languages-and-explain-with-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5839862175256609756'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5839862175256609756'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/what-are-the-relational-operators-in-c-languages-and-explain-with-examples.html' title='Relational Operators in C Languages'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-1070141259739589199</id><published>2016-11-15T23:29:00.003+05:30</published><updated>2017-01-05T20:16:57.278+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Operators in C Languages</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;b&gt; Operators : &lt;/b&gt; C support a rich set of built in operators. An operator is a symbol that tells the computer to perform certain mathematical or logical manipulations. Operators are used in the programs to manipulate data and variables.&lt;br /&gt;C Operators can be classified in to the following categories :&lt;br /&gt;&lt;ol&gt;&lt;li&gt;&lt;b&gt;Arithmetic Operators&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Relational Operators&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Logical Operators&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Assignment Operators&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Increment and Decrement Operators&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Conditional Operators&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Bitwise Operators&lt;/b&gt;&lt;/li&gt;&lt;li&gt;&lt;b&gt;Special Operators&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h1&gt;1. Arthimetic Operators : &lt;/h1&gt;C provides all the basic arithmetic operators.&lt;br /&gt;The operators +,-, * and / all work the same way as they do in other languages. These can operator on any built in data type allowed in C.&lt;br /&gt;Integer division operation truncates any fractional part(or) it gives the quotient of an integer division.&lt;br /&gt;The modulo division operation products the remainder of an integer division. &lt;br /&gt; All arithmetic operators are binary operators, because they act on two operands, The operators *, /, % will be given the highest priority over + and -. &lt;br /&gt;When equal priority operators are there in an expression, the operators will be evaluated from left to right i.e they follow left to right associativity &lt;br /&gt;&lt;div class=&quot;well well-sm&quot;&gt;Examples : &lt;br /&gt;sum = b + c; sub = b - c; mul = b * c; &lt;br /&gt;div = b / c; rem = b % d; &lt;br /&gt;Example : arithmetic expression : a = b / c * d; &lt;br /&gt;when b = 10, c = 5, d = 3, the value of a = 6. &lt;br /&gt;Here b, c, d are variables and are known as operands. &lt;/div&gt;The symbols *, / are known as operators (Arithmetic operators).&lt;br /&gt;&lt;table class=&quot;table table-bordered&quot;&gt;  &lt;tbody&gt;&lt;tr&gt;   &lt;th&gt;&lt;b&gt;Operator&lt;/b&gt; &lt;/th&gt;   &lt;th&gt;&lt;b&gt;Meaning&lt;/b&gt; &lt;/th&gt;   &lt;th&gt;&lt;b&gt;Examples&lt;/b&gt; &lt;/th&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td&gt; + &lt;/td&gt;  &lt;td&gt; Addition &lt;/td&gt;  &lt;td&gt; 1 + 2 = 3 &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td&gt; - &lt;/td&gt;  &lt;td&gt; Substraction &lt;/td&gt;  &lt;td&gt; 3 - 2 = 1 &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td&gt; * &lt;/td&gt;  &lt;td&gt; Multiplication &lt;/td&gt;  &lt;td&gt; 2 * 2 = 4 &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td&gt; / &lt;/td&gt;  &lt;td&gt; Division &lt;/td&gt;  &lt;td&gt; 3 / 2 = 1 &lt;/td&gt; &lt;/tr&gt;&lt;tr&gt;  &lt;td&gt; % &lt;/td&gt;  &lt;td&gt; ModuloDivision &lt;/td&gt;  &lt;td&gt; 10 % 3 = 1 &lt;/td&gt; &lt;/tr&gt;&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class=&quot;well well-sm&quot;&gt;&lt;b&gt; Note : &lt;/b&gt; &lt;br/&gt;&lt;ol&gt; &lt;li&gt; The modulo division operator % cannot be used on floating point data.&lt;/li&gt; &lt;li&gt; C does not have an operator for exponentiation.&lt;/li&gt; &lt;li&gt; ANSI C supports unary plus&lt;/li&gt;&lt;/ol&gt;&lt;/div&gt;&lt;p&gt;Arithmetic operations are of the following three types : &lt;/p&gt;&lt;ul style=&quot;list-style-type:none;&quot;&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Integer arithmetic &lt;/li&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Real arithmetic &lt;/li&gt; &lt;li&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Mixed mode arithmetic &lt;/li&gt;&lt;/ul&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt;  Integer Arithmetic &lt;/h1&gt;&lt;p&gt; When both the operands in a single arithmetic expression such as a + b are integers, then the expression is called integer expression, and the operation is called integer arithmetic. Integer arithmetic always yields an integer value. The largest integer value depends on the machine. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; &lt;b&gt;Example : &lt;/b&gt; &lt;br/&gt;  For a = 14 and b = 4, we have the following results : &lt;br/&gt;  a - b = 10, a + b = 18, a * b = 56 &lt;br/&gt;  a / b = 3 (decimal part truncated), a % b = 2 (reminder of division) &lt;/div&gt;&lt;p&gt; During integer division, if both the operands are of the same sign, the result is truncated towards zero. If one of them is negative, the direction of truncate is implementation dependent. That is 6 / 7 = 0 and -6 / -7 = 0 &lt;/p&gt;&lt;p&gt; But -6 / 7 may be zero or -1 (Machine dependent)&lt;/p&gt;&lt;p&gt; Similarly, during modulo division, the sign of the result is always the sign of the first operand( the dividend). That is &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; -14 % 3 = -2 &lt;br/&gt; -14 % -3 = -2 and 14 % -3 = 2 &lt;/div&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Real arithmetic : &lt;/h1&gt;&lt;p&gt;   An arithmetic operation involving only real operands is called &lt;b&gt;Real arithmetic.&lt;/b&gt; A real operand may assume values either in decimal or exponential notation. Since floating point values are rounded to the number of significant digits permissible, the final value is an approximation of the correct result.&lt;br/&gt;&lt;br/&gt;If x, y and z are float, then we will have :  &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; x = 6.0 / 7.0 = 0.857143 &lt;br/&gt; y = 1.0 / 3.0 = 0.333333 &lt;br/&gt; z = -2.0 / 3.0 = -0.666667 &lt;/div&gt;&lt;p&gt;The operator % can not be used with real operands. &lt;br/&gt; The expression 30.0 % 4.0 is invalid expression. &lt;/p&gt;&lt;h1&gt;&lt;span class=&quot;glyphicon glyphicon-arrow-right&quot; aria-hidden=&quot;true&quot;&gt;&lt;/span&gt; Mixed mode arithmetic : &lt;/h1&gt;&lt;p&gt; When one of the operands is real and the other is integer, the expression is called a mixed mode arithmetic expression. &lt;/p&gt;&lt;p&gt; It either operand is of the real type, then only real operation is preformed and the result is always a real number. Thus &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; 15 / 10.0 = 1.5 where as 15 / 10 =  &lt;/div&gt;&lt;br/&gt;&lt;nav aria-label=&quot;...&quot;&gt;  &lt;ul class=&quot;pager&quot;&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/what-are-the-relational-operators-in-c-languages-and-explain-with-examples.html&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-the-operators-in-c-languages-with-examples.html" title="Operators in C Languages"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/1070141259739589199/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-operators-in-c-languages-with-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/1070141259739589199'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/1070141259739589199'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-the-operators-in-c-languages-with-examples.html' title='Operators in C Languages'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-5363542377841022709</id><published>2016-11-15T22:18:00.001+05:30</published><updated>2017-01-05T20:18:26.679+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Formatted Output (printf) in details with examples</title><content type='html'>&lt;h1&gt;Formatted Output : &lt;/h1&gt;&lt;p&gt; &lt;b&gt;printf()&lt;/b&gt; function is used for printing captions and numerical results. It is highly desirable that the outputs are produced in such a way that they are understandable and are in any easy to use form. It is therfore necessary for the programmer to give careful consideration to the appearance and clarity of the output produced by the prograam. &lt;/p&gt;&lt;p&gt; The &lt;b&gt;printf statement&lt;/b&gt; provides certain features that can be effectively exploited to control the alignment and spacing of print-outs on the terminals. &lt;/p&gt;&lt;p&gt;The general form of printf statement : &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; printf(&quot;control string&quot;, arg1, arg2,..argn); &lt;/div&gt;&lt;p&gt;Control string consists of three types of items : &lt;/p&gt;&lt;ul&gt; &lt;li&gt;&lt;b&gt;Characters&lt;/b&gt; that will be printed on the screen as they appear.&lt;/li&gt; &lt;li&gt;&lt;b&gt;Format Specifications &lt;/b&gt;that define the output format for display of each time.&lt;/li&gt; &lt;li&gt;&lt;b&gt;Escape sequence characters&lt;/b&gt; such as \n, \t and \b.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; The control string indicates how many arguments follow and what their types are. The arguments arg1, arg2,..argn are the variables whose values are formatted and printed according to the specifications of the control string. The arguments should match in number, order and type with the format specifications. &lt;/p&gt;&lt;p&gt; A simple format specification has the following form : &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; % w.p type-specifier &lt;/div&gt;&lt;p&gt; Where w is an integer number that specifies the total number of columns for the output value and pi another integer number that specifies the number of digits to the right of the decimal point (of a real number) or the number of characters to be printed from a string. Both w and p are optional. &lt;/p&gt;&lt;h3&gt;Different ways to write the output data using printf() : &lt;/h3&gt;&lt;ol&gt; &lt;li&gt;&lt;b&gt; Outputting Integer Numbers.&lt;/b&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt; Outputting Real Numbers.&lt;/b&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt; Outputting Single Characters.&lt;/b&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt; Outputting Strings.&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h1&gt;1. Outputting Integer Numbers : &lt;/h1&gt;&lt;p&gt; The format specification for printing an integer number is : % w d &lt;br/&gt;where w specifies the minimum field width for the output. &lt;/p&gt;&lt;p&gt;However, if a number is greater than the specified field width, it will be printed in full, overriding the minimum specification. d specifies that the value to be printed is an integer. The number is written right-justified in the given field width. Leading blanks will appear as necessary. &lt;/p&gt;&lt;p&gt; It is possible to force the printing to be left-justified by placing a minus sign directly after the % character. It is also possible to pad with zeros the leading blanks by placing a 0(zero) before the field width specifier. &lt;/p&gt;&lt;p&gt;the minus (-) and zero (0) are known as flags.&lt;/li&gt;&lt;p&gt; long integers may be printed by specifying Id in the place of d in the format specification. Similarly, we may use hd for printing short integers. &lt;/p&gt;&lt;h1&gt;2. Outputting Real Numbers : &lt;/h1&gt;&lt;p&gt;  The output of a real number may be displayed in decimal notation using the format specification : % w.p f&lt;/p&gt;&lt;p&gt; The integer w indicates the minimum of positions that are to be used for the display of the value and the integer p indicates the number of digits to be displayed after the decimal point(precision). The value, when displayed, is rounded to  decimal places and printed right-justified in the field of w columns. Leading blanks and trailing zeros will appear as necessary.&lt;/p&gt;The default precision is 6 decimal places. &lt;p&gt; we can also display a real number in exponential notation by using the format specification : &lt;b&gt; % w.p e &lt;/b&gt;&lt;/p&gt;&lt;p&gt; The value will be rounded off and printed right justified in the field of w columns. Padding the leading blanks with zeros and printing with left-justification are also possible by using flags 0 or - before the field width specifier w. &lt;/p&gt;&lt;p&gt; Some systems also support a special field specification character that lets the user define the field size at run time. This takes the following form : &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; printf(&quot;%*.*f&quot;, width, precision, number); &lt;/div&gt;&lt;p&gt;In this case, both the field width and the precision are given as arguments which will supply the values for w and p. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; printf(&quot;%*.*f&quot;, 7, 2, number); &lt;/div&gt;&lt;p&gt; is equivalent to &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; printf(&quot;%7.2f&quot;, number); &lt;/div&gt;&lt;p&gt; The advantage of this format is that the values for width and precision may be supplied at run time, thus making the format a dynamic one. &lt;/p&gt;&lt;h1&gt;3. Outputting Single Characters : &lt;/h1&gt;&lt;p&gt; A single character can be displayed in a desired position using the format : &lt;b&gt; % W c &lt;/b&gt;&lt;/p&gt;&lt;p&gt;The character will be displayed right-justified in the field of w columns. We can make the display left-justified by placing a minus sign before the integer w. The default value for w is 1.&lt;/p&gt;&lt;h1&gt; 4. Outputting String : &lt;/h1&gt;&lt;p&gt; The format specification for outputting strings is similar to that of real numbers. It is of the form &lt;b&gt;% w.p s &lt;/b&gt;where w specifies the field width for display and p instructs that only the first p characters of the string are to be displayed. The display is right-justified.&lt;/p&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-formatted-output-printf-in-details-with-examples-in-c-languages.html" title="Formatted Output (printf) in details with examples"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/5363542377841022709/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-formatted-output-printf-in-details-with-examples-in-c-languages.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5363542377841022709'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5363542377841022709'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-formatted-output-printf-in-details-with-examples-in-c-languages.html' title='Formatted Output (printf) in details with examples'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-5586165167521094284</id><published>2016-11-15T20:52:00.001+05:30</published><updated>2017-01-05T20:18:40.426+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Formatted Input (scanf) in details with example in C Languge - Part 2</title><content type='html'>&lt;h1&gt;2. Inputting Real Numbers : &lt;/h1&gt;&lt;p&gt; Unlike integer numbers, the field width of real numbers is not to be specified and therefore scanf reads real numbers using the simple specification %f for both the notations, namely, decimal point notation and exponential notation. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; For example, Scanf(&quot;%f %f %f&quot;, &amp;x, &amp;y, &amp;z); &lt;br/&gt; with the input data 475.89 43.21E-1 678 &lt;/div&gt;&lt;p&gt; will assign the value 475.89 to x, 4.321 to y and 678.0 to z. &lt;/p&gt;&lt;p&gt; The input field may be separated by any arbitrary blank spaces.&lt;/p&gt;&lt;p&gt;If the number to be read is of double type then the specification should be % if instead of simple %f. A number may be skipped using % * f specification.&lt;/p&gt;&lt;h1&gt;3. Inputting Character Strings : &lt;/h1&gt;&lt;p&gt;We have already seen how a single character can be read from the terminal using the getchar() function. The same can be achieved using the scanf function also. In additional, a scanf() function can input strings with more than one character. Following are the specifications for reading character strings.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; %ws or %wc &lt;/div&gt;&lt;p&gt;The corresponding argument should be a pointer to a character array. However, %c may be used to read a single character when the argument is a pointer to a char variable.&lt;/p&gt;&lt;p&gt;&lt;b&gt;Note : &lt;/b&gt; Note that the specification %s terminates reading at the encounter of a blank space. Some versions of scanf support the following conversion specifications for strings.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; % [ characters ] &lt;br/&gt; % [ ^ characters ] &lt;/div&gt;&lt;p&gt; The specification %[charactes] means that only the characters specified within the brackets are permissible in the input string. If the input string contains any other character, the string will be terminated at the first encounter of such a character. The specification %[^characters] does exactly the reverse. That is, the characters specified after the circumflex (^) are not permitted in the input string. The reading of the string will be terminated at the encounter of one of these characters. &lt;/p&gt;&lt;p&gt;&lt;b&gt;Reading Blank Spaces : &lt;/b&gt; &lt;br/&gt; We have earlier seen that %s specifier can not be used to read strings with blank spaces. But, this can be done with the help of %[] specification. Blank spaces may be included with the brackets, thus enabling the scanf to read strings with spaces. Remember that the lowercases and uppercases letters are distinct. &lt;/p&gt;&lt;h1&gt;4. Inputting Mixed Data Types : &lt;/h1&gt;&lt;p&gt; It is possible to use one scanf statement to input a data line containing mixed mode data. In such cases, care should be taken to ensure that the input data items match control specifications in order an type. When an attempt is made to read an item that does not match the type expected, the scanf unction does not read any further and immediately returns the values read. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; The statement scanf(&quot;%d %c %f %s&quot;, &amp;count, &amp;code, &amp;ratio, name); &lt;/div&gt;&lt;p&gt; will read that data 15 p 1.575 coffee correctly and assign the values to the variables in the order in which they appear. Some systems accept integers in the place of real numbers and vice versa, and the input data is converted to the type specified in the control string. &lt;/p&gt;&lt;p&gt;&lt;b&gt;Note : &lt;/b&gt; A space before the %c specification in the format string in necessary to skip the white space before p.&lt;/p&gt;&lt;h4&gt;Detection of Errors in Input : &lt;/h4&gt;&lt;p&gt; When a scanf function completes reading its list, it returns the value of number of items that are successfully read. This value can be used to test whether any errors occurred in reading the input.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; For example : scanf(&quot;%f %f %s&quot;, &amp;a, &amp;b, name); &lt;/div&gt;&lt;p&gt;will return the value 3 if the following data is typed in : &lt;b&gt;20 150.25 motor &lt;/b&gt; &lt;br/&gt; and will return the value 1 if the following line is entered &lt;b&gt; 20 motor 150.25&lt;/b&gt;&lt;/p&gt;&lt;p&gt; This is because the function would encounter a string when it was expecting a floating-point value, and would therefore terminate its scan after reading the first value.&lt;/p&gt;&lt;h2&gt;Rules for scanf() function : &lt;/h2&gt;&lt;ul&gt; &lt;li&gt;Each variable to be read must have a filed specification.&lt;/li&gt; &lt;li&gt;For each field specification, there must be a variable address of proper type.&lt;/li&gt; &lt;li&gt;Any non- whitespace character used in the format string must have a matching character in the user input.&lt;/li&gt; &lt;li&gt;Never end the format string with whitespace. It is a fatal error !&lt;/li&gt; &lt;li&gt;The scanf reads until :     &lt;ol&gt;    &lt;li&gt;A white space character is found in a numeric specification, or &lt;/li&gt;    &lt;li&gt;The maximum number of characters have been read or &lt;/li&gt;    &lt;li&gt;An error is detected, or &lt;/li&gt;    &lt;li&gt;The end of file is reached&lt;/li&gt;   &lt;/ol&gt;&lt;/ul&gt;&lt;nav aria-label=&quot;...&quot;&gt;  &lt;ul class=&quot;pager&quot;&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-formatted-input-scanf-in-details-with-examples.html&quot;&gt;Previous&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-formatted-input-scanf-in-details-with-example-in-c-language-2.html" title="Formatted Input (scanf) in details with example in C Languge - Part 2"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/5586165167521094284/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-formatted-input-scanf-in-details-with-example-in-c-language-2.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5586165167521094284'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/5586165167521094284'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-formatted-input-scanf-in-details-with-example-in-c-language-2.html' title='Formatted Input (scanf) in details with example in C Languge - Part 2'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-4715479829039663415.post-4614809645000388310</id><published>2016-11-15T15:27:00.000+05:30</published><updated>2017-01-05T20:18:36.636+05:30</updated><category scheme="http://www.blogger.com/atom/ns#" term="C Language"/><category scheme="http://www.blogger.com/atom/ns#" term="C Theory"/><title type='text'>Formatted Input (scanf) in details with example in C Language</title><content type='html'>&lt;h1&gt;Formatted Input : &lt;/h1&gt;&lt;p&gt; Formatted input refers to an input data that has been arranged in a particular format. For example, consider the following data :  &lt;b&gt;15.75 123 John &lt;/b&gt;&lt;/p&gt;&lt;p&gt; This line contains three pieces of data, arranged in a particular form. Such data has to be read conforming to the format of its appearance. For example, the first part of the data should be read into a variable float, the second into int, and the third part in to char. this is possible in C using the scanf function. (scan means scan formatted) &lt;/p&gt;&lt;p&gt; Now, we shall see all the options that are available for reading the formatted data with scanf function. &lt;/p&gt;&lt;p&gt; General form of scanf : scanf(&quot;control string&quot;, arg1, arg2,...argn); &lt;/p&gt;&lt;p&gt; The control string specifies the field format in which the data is to be entered and the arguments arg1, arg2,...argn specify the address of locations where the data is stored. Control string and arguments are separated by commas. &lt;/p&gt;&lt;p&gt; Control string (also known as format string) contains field specifications, which direct the interpretation of input data. &lt;/p&gt;&lt;p&gt;It may include : &lt;/p&gt;&lt;ul&gt; &lt;li&gt;Field (or format) specifications, consisting of the conversion character %, data type character (or type specifier), and an optional number, specifying the field width.&lt;/li&gt; &lt;li&gt;Blanks, tabs or newlines.&lt;/li&gt;&lt;/ul&gt;&lt;p&gt; Blanks, tabs and newlines are ignored. The data type character indicates the type of data that is to be assigned to the variable associated with the corresponding argument. The field width specifier is optional. &lt;/p&gt;&lt;h2&gt;Different ways to read the input data using scanf() : &lt;/h2&gt;&lt;ol&gt; &lt;li&gt;&lt;b&gt; Inputting Integer Numbers&lt;/b&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt; Inputting Real Numbers&lt;/b&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt; Inputting Character Strings.&lt;/b&gt;&lt;/li&gt; &lt;li&gt;&lt;b&gt; Inputting Mixed Data Types.&lt;/b&gt;&lt;/li&gt;&lt;/ol&gt;&lt;h1&gt;1. Inputting Integer Numbers : &lt;/h1&gt;&lt;p&gt; The field specification for reading an integer number is : %w sd. &lt;/p&gt;&lt;p&gt; The percentage sign (%) indicates that a conversion specification follows. w is an integer number that specifies the field width of the number to be read and d known as data type character, indicates that the number to be read in integer mode. &lt;/p&gt;&lt;p&gt; Consider the following example : &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; scanf(&quot;%ed %5d&quot;, &amp;num1, &amp;num2); &lt;/div&gt;&lt;b&gt;input Data1 : 50 31426&lt;/b&gt; &lt;br/&gt;&lt;p&gt;The value 50 is assigned to num1 and 31426 to num2.&lt;/p&gt;&lt;b&gt;input Data2 : 31426 50.&lt;/b&gt; &lt;br/&gt;&lt;p&gt; The variable num1 will be assigned 31(because of % 2d) and num2 will be assigned 426(unread part of 31426). The value 50 that is unread will be assigned to the first variable in the next scanf call. This kind of errors may be eliminated if we use the field specifications without the field width specifications. &lt;/p&gt;&lt;p&gt; the statement &lt;b&gt;scanf(&quot;%d %d&quot;, &amp;num1, &amp;num2);&lt;/b&gt; will read the data 31426 50 correctly and assign 31426 to num1 and 50 to num2. &lt;/p&gt;&lt;p&gt; Input data items must be separated by spaces, tabs or newlines. Punctuation marks do not count as separators. When the scanf functions searches the input data line for a value to be read, it will always bypass any white space characters. &lt;/p&gt;&lt;p&gt; If we enter a floating point number instead of an integer, the fractional part may be truncated, also scanf may skip reading further input. &lt;/p&gt;&lt;p&gt; When the scanf reads a particular value, reading of the value wil be terminated as soon as the number of characters specified by the field width is reached (if specified) or until a character that is not valid for the value being read is encountered. In the case of integers, valid characters are an optionally signed sequence of digits. &lt;/p&gt;&lt;p&gt;An input field may be skipped by specifying * in the place of field width.&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;For example, the statement scanf(&quot;%d %*d %d&quot;, &amp;a, &amp;b)&lt;/div&gt;&lt;p&gt;will assign the data 123 456 789 as follows :&lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt; 123 to a &lt;br/&gt; 456 skipped(because of *) &lt;br/&gt; 789 to b&lt;/div&gt;&lt;p&gt; &lt;b&gt;Note 1 : &lt;/b&gt; It is legal to use a non - whitespace character between field specifications. However, the scanf expects matching character in the given location. &lt;/p&gt;&lt;div class=&quot;well well-sm&quot;&gt;For example, scanf(&quot;%d - %d&quot;, &amp;a, &amp;b); &lt;/div&gt;&lt;p&gt;accepts input like 123 - 456 to assign 123 to a and 456 to b.&lt;/p&gt; &lt;nav aria-label=&quot;...&quot;&gt;  &lt;ul class=&quot;pager&quot;&gt;    &lt;li&gt;&lt;a href=&quot;http://www.dotnetprogramer.in/2016/11/explain-formatted-input-scanf-in-details-with-example-in-c-language-2.html&quot;&gt;Next&lt;/a&gt;&lt;/li&gt;  &lt;/ul&gt;&lt;/nav&gt;</content><link rel="related" href="http://www.dotnetprogramer.in/2016/11/explain-formatted-input-scanf-in-details-with-examples.html" title="Formatted Input (scanf) in details with example in C Language"/><link rel='replies' type='application/atom+xml' href='http://www.fresherscoder.com/feeds/4614809645000388310/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-formatted-input-scanf-in-details-with-examples.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/4614809645000388310'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/4715479829039663415/posts/default/4614809645000388310'/><link rel='alternate' type='text/html' href='http://www.fresherscoder.com/2016/11/explain-formatted-input-scanf-in-details-with-examples.html' title='Formatted Input (scanf) in details with example in C Language'/><author><name>Erukulla&#39;s</name><uri>http://www.blogger.com/profile/14708762911706634382</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>