IHYPRESS PROGRAMMING
Tutorials and C programs with code and output for beginners
c programming
HOME | ASP | C | CSS | GNUPLOT | HTML | JAVASCRIPT | PERL | PHP | PYTHON | RUBY | SVG
CData Types & Operators ❯ Negation Unary Arithmetic Operator
<02.05>
/* The (-)unary operator */
#include <stdio.h> int main (void) { int a, b, c; a = 10; b = 20; /* b is 20 so -b is -20 */ b = -b + a; /* with multiple similar unary operators, use parentheses */ /* do you understand why c is 30? */ c = -b - (-a) + -b; printf ("The value of b is %d ", b); printf ("and the value of c is %d\n", c); return (0); }
Hergestellt in Deutschland / Made in Germany
The value of b is -10 and the value of c is 30
COPYRIGHT © 2015-2024 IHY PRESS Frankfurt am Main 60329 Deutschland
Earn Free Bitcoin