C Borland Compiler Error -


back basics borland c compiler. keep getting following message , driving me crazy cannot find semi colon should go or why expected

>bcc32 -v- -w -o1 oddeven.c borland c++ 5.5.1 win32 copyright (c) 1993, 2000 borland oddeven.c: error e2378 oddeven.c 16: statement missing ; in function main() *** 1 errors in compile *** >exit code: 1 

here code, in advance

/* program check if given integer between 1 , 100 odd or  date: 09/10/2015 */   #include <stdio.h>  main() {     int input;      printf("\nplease enter number between 1 , 100\n");     scanf("%d", &input);     printf("\nyou entered %d\n", input);      //for loop used error handling     for(input > 0 && input < 101)     {              if(input <= 0 && input > 100)                  {                   printf("error!! please enter number between 1 , 100");                   }//end if 1               //modulo 2 check divisibility              if(input % 2 == 0)                 {                     printf("\n %d even", input);                 }//end if 2              else                 {                     printf("\n %d odd", input);                 }//end else      }//end loop          getchar();         getchar();  }//end main 

this:

for(input > 0 && input < 101) 

is invalid syntax. should be

while(input > 0 && input < 101) 

but have infinite loop on entering valid. should if, then, no error message printed when user enters invalid number. should move

if(input <= 0 && input > 100) {     printf("error!! please enter number between 1 , 100"); }//end if 1 

outside if.

there lot of other problems well. suggest read c book.

fixed code:

/* note how code indented , looks clean */  #include <stdio.h>  int main(void) /* valid signature of main */ {     int input, c; /* note variable */      printf("\nplease enter number between 1 , 100\n");     scanf("%d", &input);      printf("\nyou entered %d\n", input);      if(input <= 0 || input > 100) /* note use of || instead of && */     {         printf("error!! please enter number between 1 , 100 \n");     }     else /* note else */     {         if(input % 2 == 0)         {             printf("\n %d \n", input);         }         else         {             printf("\n %d odd \n", input);         }     }      while((c = getchar()) != '\n' && c != eof); /* clear stdin */     getchar(); /* wait character */ } 

Comments

Popular posts from this blog

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -