#include<bits/stdc++.h>
using namespace std;
bool isPrime(int num){
for(int i=2;i<num;i++){
if(num%i == 0)
return false;
}
return true;
}
int main(){
int n;
int arr[1004],mularr[1004];
int count = 0,mulCount=0;
cout << "Enter a number between 0-1000: ";
cin >> n;
while(n>1000 && n<0){
cout << "Enter a number between 0-1000: ";
cin >> n;
}
cout << endl;
for(int i=2;i<=n;i++){
if(isPrime(i)){
arr[count] = i;
count++;
}
}
cout << "Total number of prime numbers found: " << count << endl;
for(int i=0;i<count;i++)
cout << arr[i] << endl;
cout << endl;
for(int i=0;i<count/2;i++){
mularr[mulCount] = arr[i]*arr[count-i-1];
mulCount++;
}
cout << "Total number of elements in the multiplication output array: " << mulCount<<endl;
for(int i=0;i<mulCount;i++)
cout << mularr[i] << endl;
}
Program Requirements First, find all the prime numbers between 2 and a user-inputted number from the...
In C program #include<stdio.h> The first 11 prime integers are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, and 31. A positive integer between 1 and 1000 (inclusive), other than the first 11 prime integers, is prime if it is not divisible by 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, and 31. Write a program that prompts the user to enter a positive integer between 1 and 1000 (inclusive) and that outputs whether the number...
(Done in Eclipse Java) 1. Given an integer between 1—100 captured from a user, perform the following conditional actions: • If is odd, print Weird • If is even and in the inclusive range of 2 to 5, print Not Weird • If is even and in the inclusive range of 6 to 20, print Weird • If is even and greater than 20, print Not Weird Note: Validate that your algorithm works for all cases. 2. Read an integer...
Write a program that finds and output all of the prime numbers between 2 to 2000 to the display screen. You are to declare any required array in main and pass them to your function sieve that will process the array.C++
Write a program that check odd / even numbers (from number 1 to
100). Display the results within an HTML table with 2 columns: one
for odd number and one for even numbers.
NUMBERS RESULTS ODD EVEN ODD 2 HINT: use <table> tags to create a table, <th> tags for 'Numbers' and 'Results'. Wrap code PHP inside HTML code. For example: <html> <title>CHECK ODD or EVEN</title> <body> <table> ?php echo "<tr><td>l</td><td>Odd</td</tr>"; </table> </body </html 2. Do the following steps in...
The task involves writing a C++ program that determines the prime numbers between 1 and 100. The steps you should follow to identify the prime numbers are the following. 1. The number 1 is not a prime number, so it should be scratched. 2. Starting from the first prime number, which is 2, you scratch all the numbers that are the multiple of 2. You should not scratch out 2 itself. 3. The next number in the sequence after the...
Prime Number Programing in C Note: The program is to be written using the bitwise operation. Use an integer array (not a Boolean array) and a bit length (for instance 32 bits). In this program you will write a C program to find all prime numbers less than 10,000. You should use 10,000 bits to correspond to the 10,000 integers under test. You should initially turn all bits on (off) and when a number is found that is not prime,...
For C++ program Your program should first prompt the user for the number of students they wish to enter. For each student, the user will be prompted to enter the student’s name, how many tests the student has taken, and the grade for each test. Each test’s grade will be inputted as a number representing the grade for that test. Once each student’s information has been entered, the program will display the number of students. Additionally, each student will have...
Use phyton TheSieve of Eratosthonesis an algorithm to find all the prime numbers between 1 andsome integerN. It can be implemented with nestedforloops:(a) Make a list of all the integers from 2 throughN.(b) Cross off all the multiples of 2 (except for 2 itself). The smallest number that remains(after 2) is 3.(c) Cross off all the multiples of 3 (except for 3 itself). The smallest number that remainsis 5.(d) Cross off all the multiples of 5 (except for 5 itself)....
write a complete Java program with comments in main and in each method. Data: The input data for this program is given as two columns of numbers. All data will be entered from a fle named input.txt and all output will go to the screen Assume there will not be more than 100 7 23.56 16 88.12 10 75.1 Design a Java class with a main method that does the following 1) Reads the data into two arrays of doubles,...
In C++ This program will read a group of positive numbers from three files ( not all necessarily the same size), and then calculate the average and median values for each file. Each file should have at least 10 scores. The program will then print all the scores in the order that they were input, showing each number and what percentage it is above or below the average for each file. Note: Finding the average doesn’t require an array. Finding...