Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


A MobileNumber is a VIP number if it satisfy the following
conditions.

The operator should be Vodafone.
Atleast one 0 (Zero) should be exist in mobile number.
The number should not end with 8.
The single digit sum of all the digits in the number should
be equal to 9. For example if the number is 9876543210, the
sum is 9+8+7+...+1+0 = 45. Sum of 4+5 = 9.
Write a method:

private boolean isVIPMobileNumber(String mobileNum, String
operator)

mobileNum phone number
operator mobile operator as bsnl, Vodafone



A MobileNumber is a VIP number if it satisfy the following conditions. The operator should be V..

Answer / c.p.senthil

// The prototype in question is not exactly c language. but i tried to provide equivalent solution in c.

int SingleDigitSum(int num)
{
int hund, tens, ones;
int sum = 0;

sum = num;

do
{
hund = sum / 100;
sum = sum % 100;
tens = sum / 10;
ones = sum % 10;
sum = hund + tens + ones;
}
while(sum > 9);

return(sum);
}

boolean isVIPMobileNumber(String mobileNum, String operator)
{
int i, sum=0, zeroCnt=0;
int tens, ones;
boolean retValue = FALSE;

// check for Vodafone operator
if(strcmp("Vodafone", operator) == 0)
{
// validate length of mobile number including NULL
if(strlen(mobileNum) == 11)
{
// check for the number should not end with 8
if(mobileNum[9] != 8)
{
for(i=0; i<10; i++)
{
if(mobileNum[i] == '0') zeroCnt++;

sum += mobileNum[i];
}

// Atleast one 0 (Zero) should be exist in mobile number.
// The single digit sum of all the digits in the number should be equal to 9.

// maximum sum possible single digit sum = 9+9+9+9+9+9+9+9+9+9 = 90 = 9 + 0 = 9

if((zeroCnt != 0) && (SingleDigitSum(sum) == 9))
{
retValue = TRUE;
}
}
}
}
}

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More C Interview Questions

what is the output of the following program? #include<stdio.h> void main() { int x=4,y=3,z; z=x-- -y; printf("\n%d %d %d",x,y,z); }

14 Answers  


What is the value of a[3] if integer a[] = {5,4,3,2,1}?

0 Answers  


Explain what happens if you free a pointer twice?

0 Answers  


difference between semaphores and mutex?

1 Answers  


What is the process to generate random numbers in c programming language?

0 Answers  


What is the Purpose of 'extern' keyword in a function declaration?

0 Answers  


What is a pointer variable in c language?

0 Answers  


What was noalias and what ever happened to it?

0 Answers  


what is the syallabus of computer science students in group- 1?

0 Answers  


what is the different between if-else and switch statment (other than syntax)

26 Answers   CTS, Oracle, Scorpos,


When should we use pointers in a c program?

0 Answers  


How do you define a string?

0 Answers  


Categories