xachetbay

Hàm kiểm tra chẵn lẻ

Mar 18th, 2019
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.30 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<conio.h>
  3.  
  4. int ktraChanLe(int a){
  5.     if(a % 2 == 0){
  6.         return 1;
  7.     }else {
  8.         return 0;
  9.     }
  10. }
  11.  
  12. int main(){
  13.     printf("Nhap so: ");int b;scanf("%d",&b);
  14.    
  15.     if (ktraChanLe(b) == true ){
  16.         printf("Day la so chan");
  17.     }else{ 
  18.         printf("Day la so le");
  19.     }
  20.    
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment