Advertisement
Guest User

Untitled

a guest
Jan 22nd, 2017
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.76 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. int main(void)
  4. {
  5.    int num1, num2, digit, numOut;
  6.    
  7.    
  8.    
  9.     printf("Enter a three-digit number: ");
  10.     scanf("%d", &num1);
  11.     printf("%d", num1);
  12.    
  13.  
  14.    
  15.    if(num1<100 || num1>999)
  16.    {
  17.        
  18.        printf("Error : The number you have entered is not a three-digit number.\n");
  19.        
  20.  
  21.    
  22.        return 0;
  23.    }
  24.  
  25.  
  26.    
  27.       while(num1>0)
  28.    {
  29.        
  30.        digit = (num2+6)%10;
  31.        num2 = num1%10;
  32.        
  33.      
  34.        if(num1>100)
  35.            numOut = digit;
  36.      
  37.        else if(num1>10)
  38.            numOut = (digit*10)+numOut;
  39.      
  40.        else
  41.            numOut = (digit*100)+numOut;
  42.          
  43.        num1 / 10;
  44.    }
  45.  
  46.    
  47.    printf("Output: %d\n", numOut);
  48.  
  49.    return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement