0

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..??

3
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by Aia
0

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. :)

0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.