Thursday, March 13, 2014

Mathematical operators

Mathematical expressionsExpressed in the CProcess
. X or nothing*multiplication
Mode%Modular quotient
//Quotient
+1++Unary increment
-1--Unary decrement
++Sum
--Difference

The expression of meaning may change for operator location. The right or left is important.
headerheader
A++ (postincrement)Firstly use A, than add 1 to the number.
++A ( preincrement )Firstly add 1 to the A, after use number.
A -- ( postdecrement )Firstly use A, than subtract 1 to the number.
-- A ( predecrement )Firstly subtract 1 to the A, after use number.


An example of a difference in meaning of change unory operator location; For example, should it be : a=4, b=5

headerheaderheaderheaderheaderheader
c=a++ *bc=a*b
a=a+1
c=4*5=20
a=4+1=5
a=5b=5c=20
c=++a–ba=a+1
c=a - b
a=4+1=5
c=5 - 5=0
a=5b=5c=0
c= -- a + b --a=a+1
c=a+b
b=b - 1
a=4 - 1=3
c=3+5=8
b=5 - 1=4
a=3b=4c=8
+/- Click and see the code that is about the article.
/* source : freelearncprogramming.blogspot.com */
#include <stdio.h>
main ()
{
int a,b,c;
float c1;
a=4;
b=5;
c=a++*b ;
c1=++a-b ;
printf ("c = %d \n",c);
printf ("c1 = %d \n",c1);
return 0;
}

No comments:

Post a Comment