primesdesign - #include #include...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
#include <stdio.h> . #include <stdlib.h> #include <ctype.h> #define HIGH 32500 short int CPSP_sum( short int a[], short int b); void print_primes( short int a[], short int b); short int prime_diff( short int a[], short int b); main() { short int first[HIGH]={0}, second[HIGH]={0}, numP, order, sum, j, k, i, list, compare, prime, sum_t, diff_t; char insane, fu, end; printf( "Enter number of primes:" ); scanf( "%hd" , &numP); for ( ; ; ){ if ( numP <= 500 ){ for (order = 0, i = 0 ; i < HIGH ; i++){ /*puts the array in numerical order by incrementing a counter and array variables */ first[i]=order; ++order; } for (j = 2 ; j < numP ; j++){ /*find all prime numbers in array by adding a sum variable to a*/ for (sum = j ; sum < HIGH; ){ /*fixed variable multiple times to find all multiples of every number and sets that number in array to 0*/ sum = sum + j; first[sum]=0; } } for (list = 0, k = 0; k < HIGH ; ++k){ /*copies only primes to second array by finding those numbers that are not zero set by previous loop*/
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/01/2008 for the course EE 312 taught by Professor Shafer during the Spring '08 term at University of Texas.

Page1 / 3

primesdesign - #include #include...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online