write a program that reads in an integer and then determines if its even or odd.
#include %26lt;stdio.h%26gt;
int main()
{
int number;
printf(" Enter an integer\n");
scanf("%d", %26amp;number);
{
if (number%2==0);
printf("Integer is even\n");
{
if (number%2!=0);
printf(" integer is odd\n");
}
}
}
Any sugestions would be appreciated. help with c?
Do not put a semicolon after your if statements. Your program will print that the integer is odd and even every time. Also, an if...else statement is all that is necessary to check if the number is even or odd, not two if statements.
#include %26lt;stdio.h%26gt;
int main()
{
int number;
printf(" Enter an integer\n");
scanf("%d", %26amp;number);
if (number%2==0) printf("Integer is even\n");
else printf("Integer is odd\n");
return 0;
}
Reply:It should work,, use the one the person answers
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment