1. Division Operations/
An integer In addition to an integer or an integer. Operands that participate in an operation must be of the same type.
The value of 1/2 is 0. What is the type of operand that participates in the operation, and what type is the resulting value. 10.5 + 10 will elevate the right 10 to double type automatic type promotion.
int B = 10.5 + 1.7; Converting a large type to a small type automatically loses precision.
Double A = (double) 1/2; Note: The participation in the operation is the integral type, so be strong to turn a bit.
2. Residual operation% (modulo operation)
% can only be integers on both sides.
The positive and negative values depend on the value of% left.
#include <stdio.h>intMain () {intinput; intminute; intsecond; printf ("Please enter a time value (seconds): \ n"); scanf ("%d",&input); Minute= input/ -; Second= input% -; printf ("you entered:%d minutes%d seconds \ n", Minute,second); return 0;}
C language-02 basic operations