Program to split of a 4 digit number

 
     # include <iostream.h>
     int main( )
     {
    int x = 1234, y, z;
    y = x /1000 ;   
    cout << "The digit in the Thousand's place =  "<<y;
    z = x % 1000;
    y = z /100;
    cout << "\nThe digit in the Hundred's place =  "<<y;

    z = z % 100;
    y = z / 10;
    cout << "\nThe digit in the Ten's place =  "<<y;

    y = z % 10;
    cout << "\nThe digit in the Unit's place =  "<<y;
    return 0;
      }

0 comments:

Post a Comment

 
 
 
 


Copyright © 2012 http://codeprecisely.blogspot.com. All rights reserved |Term of Use and Policies|