Thread: HElp please and thank you

  1. #1
    Registered User
    Join Date
    Mar 2017

    HElp please and thank you

    ARRAY to a for loop

    #include <stdio.h>      
    main ( )
        int i, num[4];
        int oddNumbers =0,evenNumbers =0;
        for(i=0; i<=3; i++)     
      printf("Enter a number betweem -20 and + 20 \n");
       if (num [i] <-20 || num [i] > 20  )      
      printf("number you entere outside the limits");
      i=i -1;
        for (i=0;i< 3; i++)     //   i don;t understand why this is bad""
           if (num[i] % 2 == 0)
                   evenNumbers = num[i];
                   printf("Even Numbers: %d",evenNumbers);        
                   oddNumbers = num[i];
            printf("Odd Numbers :%d",oddnumbers);               
         //  printf("Even Numbers: %d",evenNumbers);    
           //printf("Odd Numbers: %d.",oddNumbers);    
    //I have this program i need to take the numbers i put in  and have it give me the even and odd numbers. Not sure but its not giving me the numbers i put in.  .

  2. #2
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    The edge of the known universe
    Lines 19 to 27 need extra braces to make your intentions explicit.
    C doesn't care about your indentation (it's not python).
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Tags for this Thread