Chap. 1 : Unit 5 : Structure of C Language : Part 3

गणित म्हणजे शाळेपासून भुताप्रमाण पाठ न सोडणार सब्जेक्टindecision…आणी Mathematics मला कधीच अवघड गेल नाही अशी समजूत असेल तर M2 चा पेपर दिलेल्यांना विचारा crying मी म्हणतो ते खरयं की नाही ते…तर मग प्रोग्रॅमिंग लॅंग्वेज कशी त्याला अपवाद असेल? पण या ठिकाणी डेनीस गुरूजीनी गरजे नुसार त्यांच्या नियमा मध्ये थोडाफार फरक केला आहे. समजून घ्यायचा महत्वाचा पार्ट म्हणजे तोच… !enlightened

Arithmetic Instructions

It simply means mathematical equations or formulas. In arithmetic instruction in C, variable is always on the left hand side of assignment operator and constant or expression is on the right hand side of assignment operator. For example int x, sum. float average, pi, x = 5, pi = 3.14, sum = m1 + m2 + m3, average = total /5 are example of arithmetic instructions.

Very important point here is equal to operator in C is actually called as assignment operator. So instead of reading the statement x = 5, it should be read as “5 is assigned to x”….!

Last 4 statements are example of arithmetic instructions. If you closely observe all of these statements, you will find that constant or value of the expression on the right hand side is assigned to variable on the left hand side of assignment operator…

In the above example, 5 and 3.14 are integer and floating point constants where as m1, m2, m3, average, sum, pi, and x are name of variables. Collectively these are called operands when used in expressions whereas assignment, plus, and division are called as operators. So operators operate upon operands.

C language is very rich in operators say almost 50 and Dennis has cleverly used all these special characters as operators. All these operators have been divided into three broad categories viz. unary operators, binary operators and ternary operators.

Unary operator has got one operand, binary has got two operands and that of ternary obviously has got three operands

These all operators have been further categorized into sub categorized like arithmetic operators, relational operators, assignment operators, logical operators and so on but at one go we will not discuss all of these. Right now we will limit our discussion to only arithmetic operators  namely addition operator, subtraction operator, multiplication operator, division operator and modulus operator  all of which are binary operators except minus which is unary as well as binary in C language.

For example let’s consider two statements 5 plus 4 minus 1 assigned to x and sum divided by 5 assigned to average

Here 5, 4, 1, x, average, sum and 5 are called as operands and plus, minus, and division are called as arithmetic operators. In C percentile sign gives remainder of division of two numbers so for example 25 mod 3 assigned to x statement when gets executed store 1 in x as remainder. But 25 / by 3 assigned to x will give the output as 8.

The reason is in C if both operands are integer then result of their operation is integer where as result would be float if either or both of operands are float for example if x is a float variable then 25 / 3.0 gives output as 8.33. if you can recall mathematics in school, product of -4 and 5 is -20 because one of them is negative

Access this framework with lot more stuff like C language MCQ, viva and interview preparation, Glossary, Solved Programs of C language etc. please register for Discount Coupon


Leave a Reply