ithelp
Nearly a Posting Maven
2,230 posts since May 2006
Reputation Points: 769
Solved Threads: 128
It seems as if you have a solution in mind, why don't you try to implement it and if you have any trouble, post your code along with the question. (Something like "I expected it to do ___ but it is doing ___")
Oh, and when posting c code, please use c code tags
[code=c]
/* Your code here */
[/code]
Murtan
Practically a Master Poster
671 posts since May 2008
Reputation Points: 344
Solved Threads: 116
You can enter the first mobile number
scanf("%d",&mobileno[0];
rest all the numbers will be as
for(i=0;i<n;i++)
mobileno[i+1]=mobile[i]+1;
ajay.krish123
Junior Poster in Training
90 posts since Nov 2008
Reputation Points: 6
Solved Threads: 9
Please don't answer each post since your last with the same string, we all have to read through all of them.
I can't imagine any phone system where you can pre-order sequential 7 digit phone numbers, but ignoring that for now...
Why does the 7 digit phone number have to be a string?
Or if it does, why can't you convert it from a string to a number, add one and convert it back?
If you're REALLY desperate, you could convert the last character of the phone number to a number and add 1. If the number is now 10, put a '0' down for the last digit and 'carry' the one to the next-to-the last character. (At least that's how I learned to do manual addition when I was in school.)
Murtan
Practically a Master Poster
671 posts since May 2008
Reputation Points: 344
Solved Threads: 116
What about the rest of the post?
Why can't you convert from a string to a number, add one and convert it back?
And if an employee didn't have a mobile, I'd leave the field blank, not fill it with zeros.
Murtan
Practically a Master Poster
671 posts since May 2008
Reputation Points: 344
Solved Threads: 116
What code have you tried until now??
ajay.krish123
Junior Poster in Training
90 posts since Nov 2008
Reputation Points: 6
Solved Threads: 9
It's quite simple, you take
char phone[] = "0000000";
Then write a function to do addition like you would on paper.
char phone[] = "0000001";
When you get to
char phone[] = "0000009";
the next one will be
char phone[] = "0000010";
Salem
Posting Sage
11,531 posts since Dec 2005
Reputation Points: 5,862
Solved Threads: 953
Or just convert to int, add one, then convert back to string, as previously suggested
char phone[] = "0000000";
int ph = atol(phone)+1;
sprintf(phone,"%08d", ph);
Ancient Dragon
Retired & Loving It
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343