Difference between revisions of "C оператори"

From Ilianko
Line 9: Line 9:
 
  ++a <=> a = a + 1 ; --a <=> a = a - 1
 
  ++a <=> a = a + 1 ; --a <=> a = a - 1
 
</pre></code>
 
</pre></code>
 +
 +
<source lang="c">
 +
int main()
 +
{
 +
int a = 1, b = 2;
 +
 +
a++;
 +
printf(" a = %i \n" , a);
 +
printf(" a++ = %i \n" , a++);
 +
printf(" ++a = %i \n" , ++a);
 +
 +
 +
a = 1; b = 2;
 +
a = b++; //  <=>  a = b; b = b + 1;
 +
printf("a = b++; b = %i \n" , b);
 +
printf("a = b++; a = %i \n" , a);
 +
 +
a = ++b; //  <=>  b = b + 1; a = a;
 +
printf("a = ++b; b = %i \n" , b);
 +
printf("a = ++b; a = %i \n" , a);
 +
 +
return 0;
 +
}
 +
 +
</source>
  
 
== Сравнителни <code>== != > < >= <= </code> ==
 
== Сравнителни <code>== != > < >= <= </code> ==

Revision as of 09:32, 23 March 2011

Математически + - * / %

 int a = 1, b = 2;
 a + b  = 3;
 a - b = -1;
 a * b = 2;
 a / b = 0; 
 a % b = 1
 ++a <=> a = a + 1 ; --a <=> a = a - 1

<source lang="c"> int main() { int a = 1, b = 2;

a++; printf(" a = %i \n" , a); printf(" a++ = %i \n" , a++); printf(" ++a = %i \n" , ++a);


a = 1; b = 2; a = b++; // <=> a = b; b = b + 1; printf("a = b++; b = %i \n" , b); printf("a = b++; a = %i \n" , a);

a = ++b; // <=> b = b + 1; a = a; printf("a = ++b; b = %i \n" , b); printf("a = ++b; a = %i \n" , a);

return 0; }

</source>

Сравнителни == != > < >= <=

Логически

Побитови

За присвояване




[Оператори в C и C++]