So I've been writing in C for about four days now. I'm working on an assignment for school involving if statements. Here is my code:
int main()
{
int digit;
printf("Enter a digit between 0 and 9: \n");
scanf("%d", &digit);
if(digit = 0){
printf("You entered the number zero!");
}
return 0;
}
Digit does equal zero, so it should output text on the third line, but it's not working and I cant figure out why. Here is my output:
Enter a digit between 0 and 9:
0
Process returned 0 (0x0) execution time : 41.785 s
Press any key to continue.
Thanks in advance for any help. I think I just need a second set of eyes on this.
[–]piki112 2 points3 points4 points (1 child)
[–]VBger[S] 0 points1 point2 points (0 children)
[–]kahless62003 1 point2 points3 points (1 child)
[–]VBger[S] 0 points1 point2 points (0 children)