68 319
Assignments Done
99%
Successfully Done
In November 2018

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
Expert's answer
#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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions