primesdesign

# primesdesign - #include #include...

• Notes
• 3

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

#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*/ if ( first[k] > 1 ){ second[list] = first[k]; ++list; } else ; } print_primes(second, numP); /*call the print primes function*/ for ( ; ; ){ /*makes infinite loop to test user input*/ printf(

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

This is the end of the preview. Sign up to access the rest of the document.
• Spring '08
• Shafer
• Prime number, short int, short int CPSP_sum, short int prime_diff

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern