+ 3
Long input
#include <iostream> using namespace std; int main() { unsigned long long int c; cin>>c; while(c>=10){ c/=10; } cout<<c; return 0; } If I give input as: 93099339395097728908 It doesn't give the correct output which is 9 why???
5 Answers
+ 3
Your value might be or is longer than max value allowed by that type , for max value you can check by using,
cout<<ULLONG_MAX;
Also go through the following article,
https://www.google.com/amp/s/www.geeksforgeeks.org/maximum-value-of-unsigned-long-long-int-in-c/amp/
+ 2
A.S. it does not print the correct output for larger input how can I fix it, use the input I mentioned in the question.
0
What u want to know this code is working it will c/10 will sperate your last number . Use cout inside loop and print values u will understood how its working
#include <iostream>
using namespace std;
int main() {
unsigned long long int c;
cin>>c;
while(c>=10){
c/=10;
cout<<c<<" ";
}
return 0;
}
0
HK Lite stores your data in form of strings array after that conver it into int
0
you can also use auto keywords but it cannot store big integers