28 AnswersNew Answer
28 AnswersNew Answer
A string a phone number isnt an integer its rather a string as you wont be performing subtraction or division or anything of that sort.
You can use string/array for it. Although you are dealing with numbers here but generally we don't do arithmatic operations with mobile number I think array/string should be a nice chooce
If we see logically mobile number consists of all numbers and not any special character or letter so it should be saved in integer category......but it's up to the user they can save it into a string format too coz they are not going to perform operations on mobile number it,s more of a personal data than an mathematical number.
Whosoever has downvoted my answer is stupid. It was just a suggestion that it can be stored like this as well. Completely unnecessary.
Bro, no worries. you gave your opinion.👍👍👍👌👌
Typically, a numerical data type would be used. If you can moderate how the user enters it (Such as removing any dashes / spaces) you could use a numeric data type.
This would do I guess long long a = 1234567890; printf("%lld",a);
if we see logically mobile number consists of all numbers and not any special character or letter so it should be saved in integer category......but it's up to the user they can save it into a string format too coz they are not going to perform operations on mobile number it,s more of a personal data than an mathematical number. hope it helps :)
We use string bro
integer data type
I would use a string. People tend to include spaces or dashes in their numbers, or for international numbers a + with country code. Some people put brackets around (area code) and most importantly, a lot of phone numbers without country code start with a 0. int 0612345678 would get stored as 612345678 with the 0 getting dropped. Too much room for variation and depending on what you want to do with the phone numbers, save yourself from going through the effort of making it an int/long and making a regex for all the cases I mentioned. If you go for an int you should make sure it can store like 32 bits so depending on your language an int is probably fine unless a long is 32 bit for historic reasons in a dinosaur language.
Int data type
mobile number can be stored as long int ; and %ld as specifier
I think it is of Long int data type
You can use either string of character or int(long..). I think string of character will be bit easy .
I think it's an interger and also it is a string
Sandeep singh it's not int datatype it is...long long .dt
int data type
Sololearn Inc.4 Embarcadero Center, Suite 1455
Send us a message