The idea: Using looping methods and the IF constrcut to print the numbers between 1 and 10 along with an idications of whether each is even or odd. Like this 1 is odd 2 is even 3 is odd Using C My attempt: /* Name: Cameron Owen CIC Y1 G1 Software Development Mathmatics */ Code: #include <stdio.h> void main (void) { int iCount; //decalered integar variable iCount=1; //assigning 1 to iCount clrscr(); do{ printf("%d",iCount); if(iCount, "%/2==0"); printf ("EVEN\n"); else printf ("ODD\n"); iCount++; }while(iCount<11); getch(); } i understand the basic idea for C but require further assisance. This only gives one error. Else is misplaced. I know there are other ways to do this without the need to use a maths division but that would only work for the numbers i choose. My idea is, if a number is divisable by 2 and gives a remainder 0. Then its even If a number is divisable by 2 and gives a remiander 1. It is odd Many thanks if you help me on this, Cameron
You have posted it as an Article under the Article / Source code section. I have moved it to the Queries and Discussion forum. Also please use the bbcode for the code snippets you put in.
Just replace the dowhile loop with the following Code: do{ printf("%d",iCount); if(iCount%2==0) printf ("EVEN\n"); else printf ("ODD\n"); iCount++; }while(iCount<11);