Difference between revisions of "C оператори"
From Ilianko
(Created page with " http://en.wikipedia.org/wiki/Operators_in_C_and_C++") |
|||
(11 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
+ | == Математически <code>+ - * / % </code> == | ||
+ | <code><pre> | ||
+ | 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 | ||
+ | </pre></code> | ||
+ | <code><pre> | ||
+ | #include <stdio> | ||
− | [[http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B]] | + | 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; | ||
+ | } | ||
+ | </code></pre> | ||
+ | |||
+ | == Сравнителни <code>== != > < >= <= </code> == | ||
+ | |||
+ | Логически | ||
+ | |||
+ | Побитови | ||
+ | |||
+ | За присвояване | ||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | |||
+ | [[http://en.wikipedia.org/wiki/Operators_in_C_and_C%2B%2B| Оператори в C и C++]] | ||
+ | |||
+ | |||
+ | [[Category:C Справочник]] |
Latest revision as of 09:34, 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
#include <stdio>
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;
}
</code>
Сравнителни == != > < >= <=
Логически
Побитови
За присвояване