Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

Find first and last digit of int

#include <iostream>
using namespace std;

int main()
{
    int number;
    cout << "Enter a number : " << endl;
    cin >> number;

    cout << "Last digit is : " << number % 10 << endl;

    while(number >= 10){
        number = number/10;
    }

    cout<< "First digit is : "<< number << endl;
    return 0;
}
Source by www.codevscolor.com #
 
PREVIOUS NEXT
Tagged: #Find #digit #int
ADD COMMENT
Topic
Name
7+9 =