Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- int nArr[123];
- void monitor();
- int prime_number(int n);
- int shift_the_number_to_the_left();
- ///////////////////////////////////////////////////////
- int main() //
- {
- srand(8);
- printf("Initial check of the \"prime_number()\" function: \n");
- printf(" - - - - - - - - - - - - - - - - \n");
- for(int i = 1; i < 30; i ++)
- {
- if(prime_number(i) == 1)
- printf("%3d this is a prime number \n", i);
- } printf(" \n" );
- for(int i = 0; i < 123; i++) nArr[i] = rand();
- printf("Contents of the random number array: \n");
- printf(" - - - - - - - - - - - - \n");
- monitor(); printf("\n\n");
- for(int i = 0; i < 123; i++)
- {
- if(prime_number(nArr[i]) == 1);
- else nArr[i] = 0 ;
- }
- printf("We left only prime numbers in the array: \n");
- printf(" - - - - - - - - - - - - - \n");
- monitor(); printf("\n\n");
- printf("Move all the primes to the beginning of the array: \n");
- printf(" - - - - - - - - - - - - - - - - - \n");
- while(shift_the_number_to_the_left());
- monitor();
- return 0;
- }
- /////////////////////////////////////////////////////////
- void monitor() //
- {
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement