int main() { int a=0, c, d, N, K; bool stopBool = 0;
[Code]....
This is supposed to find take a number N and K and find all numbers between 0 and N that equal K and cout the number of pairs that fit it but it doesn't work.
Find all the prime numbers between a given pair of numbers. Numbers should be read in from an input file called "numbers.txt" and find all the prime numbers between them. Store the prime numbers in an array, then sort the array from greatest to least. Display the array before and after the sort.
I'm stuck on how to put the prime numbers into an array.
The input file has the numbers 1 & 100.
Here's what I have so far.
#include <iostream> #include <fstream> using namespace std; int main() { ifstream fin; fin.open("numbers.txt");
I wrote some code for class to find prime numbers.The teacher says that I need to revise my code with the requirement below: use a bit array to store the prime number checking. The bit array will also be in the heap. Use the max value of an unsigned 32-bt integer (UINT_MAX) to be the maximum size of the prime number you want to check.
I have the random values down but when I try to assign randValue to another integer I get an error.I want to make an inner loop where I find 5 random number 50 times and print the average of those numbers.
I know I have the bare bones of the below, but without giving me a huge shove in the right direction can I have a poke? I have been programing for three months now. I have noticed when I do simple fun projects I learn more then what my professor assigned to me. The class is over but I want to keep building.C++ starts in one week...
if i have two integers, say number1 and number2, stored in arrays where each index is a digit of the number (i.e. if my numbers are 321 and 158, then number1 = {3,2,1} and number2 = {1,5,8}), can i find the remainder of number1/number2? assume number1 > number2.
I made a program that is suppose to receive 20 numbers or less and find the average, then show all numbers entered but my average does not show. It shows as 0 and a line pops up after every number returned. I am stuck and dont know how to fix the logical errors.
#include <iostream> #include <cmath> using namespace std; int main() { float num[20]; int amount_num;
I'm working on a silent auction program that will scan a file and find the highest from each group of bids, then have a running total of money made throughout the auction. I'm pretty sure the rest of my code works, i'm just getting stuck on finding the largest number from the line in the file, saving it, then moving to the next auction.
input file text (first number is num of auctions, after that it's num of bids, then the bids):
Sample Output Auction 1 sold for $500.00! Auction 2 sold for $700.00! Auction 3 sold for $300.00! Auction 4 sold for $920.00! Auction 5 sold for $50.00!
The silent auction raised $2470.00 for charity!
Code: # include <stdio.h> # include <stdlib.h> # include <time.h>
I had to write a program to find all the primes between 1 and 100 using the sieve of Eratosthenes so I wrote this program :
#include <iostream> #include <vector> using namespace std;
// find all the primes number using Eratosthenes int main() { vector<bool> numbers(101);
[Code] .....
My problem is that if I try to modify the program to find all the primes between 1 and max (setting the size of the vector uqual to max) my program becomes slower and I would like to listen by other people some possible solution to don't use vector in this program, the author hasn't shown me yet how to delete a value from a vector so I just used this method to solve the problem.