The pseudo code would be as follows (you figure out the syntax)
1) Prompt the user to enter a number
2) If entered number is alpha, quit program after displaying message that the user ended the program.
3) Otherwise, find Modulo 2 of the entered number. This is a fancy way of saying "find the remainder when the number is divided by 2)
4) If Modulo 2 is zero, the number is even, otherwise odd
5) Display message showing if the entered number was Even or Odd
6) Branch back to step 1
Chat with our AI personalities
for(int i = 1; i < 100; i+=2) { System.out.println(i); }
No, thanks.
You can use int i; for (i = 10; i <= 50; i += 2) {//print i} as a program to print even numbers between 10 and 50.
int main () { int x; printf ("Enter the value of x\n"); scanf ("%d",&x); if (0 == x%2) printf ("Number is even\n") else printf ("Number is odd\n"); }
int i, sum = 0; for (i=0; i<20; i+=2) sum+=i;