about this program


which wants only 0 and 1 integers in its input...if other digits it will say error///
how to determine it??
i don't know
is it

printf("enter a value\n");
scanf("%d",&value);

if(value2=0; value%2=1,value++){
printf("error\n");
}
else continue.


how to do it..?
i dont get the idea for geting only integers 1 and 0?
any formula..??

1. Code tags

2. Your program makes no sense. Even your problem statement is a li'l confusing. Do you want to make the user aware of the error when he inputs a number other than 0 or 1 or do you wanna convert every input into 0 or 1 using modulus operation?

3. if statement syntax is incorrect. It vaguely resembles a for statement syntax, but that doesn't solve your problem anyway.

4. What's value2?

5. If you only want to see if the user input is 0 or 1, it can be easily done as such:

printf("enter a value");
scanf("%d",&value);;
if(value!=0 || value!=1)
  printf("Error");
else
{
//continue
}

6. If you wanna convert any user value into either 0 or 1, you can use the modulus(%) operator. It's easy enough, so i'll let you figure that out yourself. :)

It appears to me you can benefit from reading a little bit more about some basic concepts of C language. Click here.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.