Attachment '8.2.c'

Download

   1 #include <stdio.h>
   2 int main( int argc, char **argv ) {
   3   int n, i, prime; 
   4 
   5   printf( "Enter n: ", n );
   6   scanf( "%d", &n );
   7   
   8   prime = 1;
   9   i = 2;
  10   while( i <= n-1 ){
  11       if( n % i == 0 )
  12         prime = 0;
  13       i = i + 1;
  14   }
  15   
  16   printf( "%d ", n );
  17   if( prime && (n != 1) )
  18     printf( "is prime\n" );
  19   else
  20     printf( "is not prime \n" );
  21       
  22   return 0;
  23 }

Attached Files

To refer to attachments on a page, use attachment:filename, as shown below in the list of files. Do NOT use the URL of the [get] link, since this is subject to change and can break easily.

You are not allowed to attach a file to this page.