Answer to Question #328635 in C++ for Nickname

Question #328635

Write a C++ program and flowchart to find first and last digit of a number

1
Expert's answer
2022-04-15T08:24:26-0400





#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS