Answer to Question #16273 in C++ for kaivndra

Question #16273
I want to write a function that takes a positive integer as input and returns the leading digit in its decimal representation. For example, the leading digit of 234567 is 2
1
Expert's answer
2012-10-10T11:54:58-0400
#include <iostream>
using namespace std;



int main (){
int a;
cin>>a;
while (a>9){
& a /= 10;
}
cout<<a<<endl;
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
APPROVED BY CLIENTS