lawrencej
asked on
How to get REJECTED to display?
This program suppose to allow the user to enter a social security nummber.
If the number matches on in the list it will display "ACCEPTED." If it
doesn't match it will display "REJECTED". To end the program the user
has to enter 000000000.
My problem with this program is when a social security number that does
not match is entered, the program displays nothing. What could be the
problem.
Everything else works fine.
This is my code:
#include <stdio.h>
#include <stdlib.h>
void main()
{
long ssn[8] = {118456835,203658739,44454 5555,51358 7652,72546 8190,79673 55113,8614 90579,9214 24023};
char buffer[25];
long l;
int x;
do
{
printf("\n\nEnter 000000000 to end program.");
printf("\nEnter Social Security Number ===>");
gets(buffer);
l=atol(buffer);
for(x=0; x<=7; x++)
{
if(ssn[x]==l)
printf("\nACCEPTED");
}
if(ssn[x]==000000000)
printf("\nSearch Completed.");
else
// if(l!=ssn[x])
printf("\nREJECTED");
}
while(l!=000000000);
}
If the number matches on in the list it will display "ACCEPTED." If it
doesn't match it will display "REJECTED". To end the program the user
has to enter 000000000.
My problem with this program is when a social security number that does
not match is entered, the program displays nothing. What could be the
problem.
Everything else works fine.
This is my code:
#include <stdio.h>
#include <stdlib.h>
void main()
{
long ssn[8] = {118456835,203658739,44454
char buffer[25];
long l;
int x;
do
{
printf("\n\nEnter 000000000 to end program.");
printf("\nEnter Social Security Number ===>");
gets(buffer);
l=atol(buffer);
for(x=0; x<=7; x++)
{
if(ssn[x]==l)
printf("\nACCEPTED");
}
if(ssn[x]==000000000)
printf("\nSearch Completed.");
else
// if(l!=ssn[x])
printf("\nREJECTED");
}
while(l!=000000000);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.