I need to create A program That makes a 12x10 Array Grid Filled With Random Numbers From 0-99.
Then I need To Allow The User To Input A Number Between 0-99 And Then The program will then search through the array and count how many of the users number there is inside the array.
Code:
#include <iostream> using namespace std; int main() { int input; int number; int row=0; int col=0; int Array [12][10];
I need to generate a grid of 10x8 and fill it with random numbers (max 70), then i need to find the smallest number within the random numbers generated and my "findSmallest" function does not seem to work and i do not know how to make it work...
Here my Code:
include <iostream> using namespace std; int main() { int row=0; int col=0; int ArrayGrid [9][11]; srand(time(NULL));
im trying to write a source code that find the smallest, largest and average of numbers in array. the code runs fine, but it is not giving the highest number and the the average should include only four number excluding highest and smallest number from the array.
void OlympicJudging() // Olympic Judging { int numbers [6]; double average, sum = 0; int temp; for(int i = 0; i < 6; i++){ cout << "Please type a value for scores: "; cin >> numbers[i];
The only part I have working is getting all odd random numbers but the logic in getting the largest and smallest from random is what is giving me alot of trouble.
class Program { static void Main(string[] args){ int num = 0; int largest = 0; Random rand = new Random(); for (int ctr = 1; ctr <= 100; ctr++)
[code]....
Console.Write("{0,5} The larget number out of 100 odd numbers is: {1:n}",y,largest);
I need to write a function with an array parameter and an int parameter.
That array has to be filled with first 10 prime numbers that are exact or higher than the int parameter... and then i need an average value of those 10 prime numbers...
The problem is im not really sure how i should do the part to fill the array with prime numbers that are higher than that int?? So any code samples that does that would be really nice... (the average part shouldnt do much problems i think, so i only need for that array fill...)
Code: int avgprimearray (int higharray[], int somenumber){ }
I seem to have reached a dead end in a program I am attempting to write.The purpose of the program is find the smallest, largest, and average values in a collection of N numbers. It needs to get the value of N before scanning each value in the collection of N numbers.I'm having trouble creating comparisons for each set. I have a feeling because of the way I structured my program, I'm unable to make a proper comparison. Maybe my approach was wrong as soon as I got to the for statement to loop N sets and N numbers.Here is my code so far:
Code:
#include <stdio.h> int main (void) { int num_sets, num_of_integers; int count, count2, set, sum = 0; int num, avg; }
[code]....
/* Here is where I would continue to attempt to make a comparison between sets to determine smallest to largest */
I need codes for a program in C or C++ that will show the real factor (the smallest one, without the number 1) when an integer is given as input.
When the program is started, it will ask to enter a number and press enter. After entering a number, it will first check if it is a prime number or not. If prime, it will notice that it is a prime number, otherwise, it will print the smallest real factor of the given integer.
For example, if 12 is entered, it will print, the smallest real factor for this number is: 2
If 27 is entered, it will print, the smallest real factor for this number is: 3
How to find the largest and smallest number entered by a user. So far I'm able to add, find the average and count how many numbers are entered.
I'm just having trouble with find the max and min. I tried if statements and it breaks the program will it wont let me exit the while loop or the program will do a force close after entering a value.
Code:
#include <stdio.h> #include <stdlib.h> int main(){
int maxNum=0, minNum=0, value, count=0, sum=0; double average;
I was assigned to create a program that has a 10 x 8 two dimensional array and fill it with random numbers in the range 50 to 70 inclusively.( Got That part down). The second part is to make function named findSmallest that will find and print, appropriately labeled, the smallest number in the array.
I cant seem to get it working. The code for finding the smallest give me some weird number
Here my Code:
//Assignment 18 Program 2 #include <iostream> using namespace std;
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...
Not a major issue since I got this to work but for some reason both my random numbers are the same and not sure why ...
using System; using System.Collections.Generic; using System.Linq; using System.Text; public class ComputerAssistedInstructions { private static Random rand1 = new Random(); private static Random rand2 = new Random();
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 have a partially filled array and I want to put that into a text file. Say I don't know how partially filled it is. How would I stop at the very end of the array where it has the last amount of data.
ex. int array[9] = {1,2,5,6}; ofstream output("txt file"); for(int i = 0;i < 9; i++){ output << array[i] }
How would I stop as soon as i becomes 4 because that is when the array stops?
I am trying to write code to find all the prime numbers before a user entered number. I started with a working program and when I tried to create a function, it got all messed up.
Code:
#include <stdio.h> int is_prime( int num ); int get_positive_integer(void); int main( ) { int upper; /* upper limit to check */ int num; /* current number to check */ int isprime; /* used to flag if number is prime or not */