How to select the first three digits from a 6-digit number in C++

1 Answer

0 votes
#include <iostream>

int main() {
    int num = 123456;   // Example 6-digit number
    
    int firstThree = num / 1000;  // Removes last 3 digits
    
    std::cout << "First three digits: " << firstThree << std::endl;
}


 
/*
run:
 
First three digits: 123
 
*/

 



answered Nov 25, 2025 by avibootz
...