Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int isPrime(int num)
- {
- int i;
- for(i = 2; i*i <= num; i++) {
- if(num % i == 0) return 0;
- }
- return 1;
- }
- int main()
- {
- int i = 0, num = 2;
- int arr[20];
- while(i < 20) {
- if(isPrime(num)) {
- arr[i] = num;
- i++;
- }
- num++;
- }
- printf("Value of the 15th position of the array: %d\n", arr[14]);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement