The source code is below.
#include <stdio.h>
int main()
{
long long n;
int count;
lable:
count = 0;
printf("Enter your contact number : ");
scanf("%lld", &n);
//know that enterd interger(contact number) have how many numbers in it
while (n != 0) {
n /= 10;
++count;
}
//if numbers are 10 then your contact number is right
if(count==10)
{
printf("contact number enterd sucessfully\n");
goto exit;
}
else
//else numbers are not 10 then invalid contact number and enter again
{
printf("In valid contact number enter again...........\n");
goto lable;
}
exit:
printf("contact number : %lld ",n);
return 0;
}
In this code, I try to enter the contact number from the user and it is checked how many numbers in your contact number, then there is 10 numbers in your contact number so it is right, but the numbers are not 10 It is showing an error and enter the number from the user again. when the number is right program is print user contact number 0. Please guide me what is the problem with this code?