C language has the The subtraction operator, including common operations such as the
take the remainder operation % : The value of the positive and negative values of the result of taking the remainder % the value of the left number is about
Arithmetic operations:
/*
Prompt for the number of seconds to enter a time, such as a few seconds to input , and then output the corresponding minutes and seconds, such as seconds is 8 points - seconds
*/
#include <stdio.h>
Int Main ()
{
// define a variable to accept the input value
Int time;
// Print Tips
Printf (" Please enter a time value of %d seconds ");
// receive a data
SCANF ("%d", &time);
// Convert seconds
int minute = TIME/60;
int second = time%60;
printf ("%d minutes %d seconds ", minute,second);
return 0;
}
Assignment operation:
Compound assignment operators: a +=5+10 ;
Self-increment/decrement:
int b,a=10;
b = (a++) + (++a);
printf ("a=%d,b=%d", A, b);
sizeof
Used to calculate the number of bytes of memory for a variable, a constant, or a data type
Relational operations
1. Conditional Judgment
2. true or false: any non- 0 The values are true, only 0 It 's a fake .
3. Relationship Comparison:>,<,==,! =,>=,<=Established as"really",Otherwise, the"Fake"
the precedence of relational operators is: left-to-right < , > , <= , >= , == , !=
The precedence of a relational operator is less than the precedence of an arithmetic operator
Logical operation:
1.&& Logic and
2.| | Logical OR
3.! Logical non-
Trinocular operator
int a=10>5?9:89
condition to be established return 9 condition not established return the
Calculates the maximum value of three numbers
#include <stido.h>
int main ()
{
int a=90,b=80,c=100,d;
int d= (A>B?A:B)? C: (A>B?A:B): C;
printf (" the largest of these three numbers is:%d", d);
return 0;
}
This article is from the "I am the way of it Growth" blog, please be sure to keep this source http://jeason.blog.51cto.com/9704473/1596331
Operations in the C language