Operations in the C language

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.