Calculation of 0 and 1 in c language

1  /* Summary about 0 and 1 
 2  Recently, I have always confused 0 and 1 for the results of / and % operations.
 So I tested it on the computer.
 4 Conclusions  :
 5          In c language, 0 / any number All 0
 6                  0% Anything is 0
 7                  1/ Anything is 0
 8                  1% Anything is remainder 1 
 9 10 */ 11 #include <stdio.h>
 12 13 int main( void )
 14 {
 15 int sum1,sum2,sum3,sum4;
 16 int a = 0 ;
 17 int b = 1 ;
 18      
 
 
                      int c = 9;
19     
20     sum1 = a/c;//    0/9 = 0;
21     sum2 = a%c;//    0%9 = 0;
22     sum3 = b/c;//    1/9 = 0;
23     sum4 = b%c;//    1%9 = 1;
24     
25     printf("%d\n%d\n%d\n%d",sum1,sum2,sum3,sum4);
26     
27     return 0;
28      
29 }

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325284507&siteId=291194637