Write a C++ program and flowchart to find first and last digit of a number
#include<iostream>
using namespace std;
int main(){
int number;
cout<<"Enter any positve integer number: ";
cin>>number;
int digit1;
int digit2=number%10;
number=number/10;
while(number)
{
digit1=number%10;
number=number/10;
}
cout<<"The first and last digit of a number are: "<< digit1<<" and "<<digit2<<"\n\n";
system("pause");
return 0;
}
Comments
Leave a comment