abhimanipal 91 Master Poster

Yet Another Version of Findind a Prime number:

#define CHK_NUM_IS_2_3_5( n )  ( n == 2 || n == 3 || n == 5 )
#define REM_2( n )  ( n % 2 != 0 ) 
#define REM_3( n )  ( n % 3 != 0 ) 
#define REM_5( n )  ( n % 5 != 0 ) 
#define CHK_REM_2_3_5( n ) ( REM_2( n ) && REM_3( n ) && (REM_5( n ) )           
                     
#include<stdio.h>

int main()
{
  int num ;
	
  REPEAT : 
    printf( "Enter a Num: " ) ;
    scanf( "%d", &num ) ;
    if( num <= 1 )
            printf(" ( %d ) is not PRIME \n " , num );
    else if  ( CHK_NUM_IS_2_3_5 ( num ) )
           printf(" ( %d ) is PRIME \n " , num );
   else if (CHK_REM_2_3_5 ( num ) )    
             printf(" ( %d ) is PRIME \n " , num );
  else
           printf(" ( %d ) is not PRIME \n " , num );
 printf(" Press < Enter > to continue..\n ");
 getchar();
 if ( getchar() < 0 )
	goto END;
goto REPEAT ;
END :
return 0;
}

i Hope this is the Efficient Version of All.
Any other ways, Plz Welcome.

I think your program will flag 49 as a prime number. 49 cannot be divided by 2, 3 or 5.

abhimanipal 91 Master Poster
union u
{
    union u
  {
      int i;
      int j;
  }a[10];
   int b[10];
}u;

main()
{
printf("n%d", sizeof(u));
printf(" %d", sizeof(u.a));
printf("%d", sizeof(u.a[4].i));
}

Hello People. I just came across this piece of C code. I have a couple of question
The third printf statement gives me the following error

pollux {~} > gcc test.c -o test
test.c: In function `main':
test.c:21: error: union has no member named `i'
pollux {~} >

I cannot understand the reason for this. Can some one shed some light on this ?