I wanted to write a program that will determine a set of values that add up to a target value. I want to use 12 bins and fill the bins with random numbers between 0 and 20. Then, look for a target value of 30.
Here is what I have so far. (mix of actual code and Pseudocode.)
#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <conio.h>
#include <stdlib.h>
int main (void) {
// columns: 0=value 1=checked 2=selected
Write a program that will generate, but not display, a three-digit "target" number that has three distinct digits. (Hint: use random number generator.) Then, input a maximum of ten user guesses and for each guess, output the number of hits and matches in the guess. Stop when the user guesses the number or runs out of guesses. For example, if the target is 427, the guess 207 has one hit (7) and one match (2).
This program does everything i want except for one major problem and one small one.
1. The program keeps taking my last entered number and counting it as max and min 2. When I go to end with 0 it adsd the enter number prompt then returns.
#include <iostream> using namespace std; int main() {
I have an array of "2,3,4,5,6,9,10,11,12,99". I need to create a table of this which i have done using case
1. Find the maximum value of the array 2. Find the sum of the first and last element of the array 3. Swap the adjacent pairs of arrays 4. Display the values in array 5. Quit
Please enter choice:
but when i try running the program i did i keep having the break or continue pop up ....
#include <iostream> using namespace std; int main() { int choice; int number[10] = {2,3,4,5,6,9,10,11,12,99};
I define "Comwords" as a string, but apparently it takes the members as chars, then I can't set strings in a structure equal to the chars.
I see to also be having unknown problems with the ComMAL array and loading it values into another element of the same structure.
How to correct this? I was thinking of casting char elements as strings, but could find no reference in my library book regarding how to do that (lots on casting int's a doubles...)
Code:
int _tmain(int argc, _TCHAR* argv[]) { int comm = 10; int targ = 5; int death; struct AI_WORDS
Using a for loop, construct two 100 element arrays, x and y, such that element i of x stores the value sin(2*pi*i/100)) and the corresponding element of y stores cos((2*pi*i/100)). Print the values stored in the elements of x and y as you calculate them.
I have attempted to solve it but I'm not sure why the value 0 is only being printed, maybe I haven't assigned sin(2i/100)) and cos((2i/100)) to the arrays properly?
Code: #include<stdio.h> #include<stdlib.h> #include<math.h> int main () {
I'm trying to write a function that takes a 32bit address and a data to store at this address.
I'm wanting to take the 32 bit memory address eg 0x12345678 and split it into 4 x 2 bytes 12, 34, 56, 78
then each of the 4 entries is at most a 256 entry array.eg FF, FF, FF, FF
So in this example, 0x12 points to 0x34 in the second array, which points to 0x56 in the third array, which finally points to 0x78 in the last array. This last array holds the actual data.
After successfully doing 0x12345678, say I might get a read for 0x1234AABB. So, the first and second pointers already exist, but I then have to create and write to dynamically created arrays.
The arrays need to have all entries set to NULL so that i know whether to follow the pointers to overwrite a previously entered value or create new arrays and pointers.
It all looks good and simple in the pseudo code I've written up but I'm having trouble coding it. I'm currently trying to deal with the first entry case, ie all array elements are NULL, but I'm getting confused with the pointers and creation of new arrays.
void cpu::store(unsigned int mem_add,unsigned int mem_val) { int first = (mem_address&4278190080)>>24; int second = (mem_address&16711680)>>16; int third = (mem_address&65280)>>8; int fourth= (mem_address&255);
Basically on this assignment I must write program that inputs two positive integers of at most 100 digits and outputs the sum of the numbers into an array. The two positive numbers must come from different arrays and the sum has to be stored into another array.
how to make the functions for b, c, d. if possible running through on how to would be more beneficial than just giving me the answer.
Global warming. As part of a global warming analysis, a research facility tracks outdoor temperatures at the North Pole once a day, at noon, for a year. At the end of each month, these temperatures are entered into the computer and processed. The operator will enter 28, 29, 30, or 31 data items, depending on the month.
You may use 500 as a sentinel value after the last temperature, since that is lower than absolute 0. Your main program should call the read_temps(), hot_days(), and print_temps() functions described here:
(b) Write a function, read_temps(), that has one parameter, an array called temps, in which to store the temperatures. Read the real data values for one month and store them into the slots of an array. Return the actual number of temperatures read as the result of the function.
(c) Write a function, hot_days(), that has two parameters: the number of temperatures for the current month and an array in which the temperatures are stored. Search through the temperature array and count all the days on which the noon temperature exceeds 32F. Return this count.
(d) Write a function, print_temps(), with the same two parameters plus the count of hot days. Print a neat table of temperatures. At the same time, calculate the average temperature for the month and print it at the end of the table, followed by the number of hot days.
#define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <stdlib.h> int main() { int a[10],b[10],c[10],i,j,k,n,m; printf ("Enter the size of the first vector: "); scanf ("%d", &n);
[Code] .....
Now, this is what I've been able to do so far, i know it's very basic but I just started learning programming! I tried different methods found on internet but none of them work for me. I want to find the intersection of arrays a & b then put them in array c(or just display them?)
I am attempting to assign "randomChoice" as the array index of the "listOfWords" array then copy "listOfWords[randomChoice] to "selectedWord". I am not sure if it is that I do not fully understand the use of strcopy() or something wrong with my arrays.
This is my error:
Code:
hangman.cc: In function ‘void SelectWord(char (*)[80], int, char*): hangman.cc:84: error: invalid conversion from 'char' to 'const char*' And my code: Code: #include <iostream>#include <fstream> #include <cstdlib> #include <cassert> #include <cstring>
This is a function that is supposed to add two different arrays containing 9 items together, but it has a problem when it comes to doing any actual adding.
Code:
int * add_data(int x[], int y[], int z[]) { int i; char a[9]; for (i=1;i!=9;i++) { printf("%d =x ", x[1]+y[1]); x[1] + y[1]= a[1]; } return a; }
If you did that bob[0] would not equal 11. All well and good right?
Now if you do this?
int sally = 33; test(sallay);
This wouldn't work at all you actually have to use
void test(int& test) { test += 10; }
how the memory addresses etc. are working here? I don't understand why you need to use & the reference operator if it's not an array? Why wouldn't that still work?
For my assignment we HAVE to use typedef to declare these. I tried a multitude of combinations using typedef, but then the rest of my code that uses songId and typeOfSong is not valid. How would I set up the correct arrays using typedef?