Set an Array (a[10]) and a Pointer to that array (*pa) and code a loop (for( ; ; loop) that will advance that pointer (*pa) and will set a new content into it with each loop. that means that in the end of the day, my program will automatically set content to each cell of the array by promoting the pointer by 1 and add the sum to that pointer.
When I run the program it prints the address of the cells instead the value of it.
Code: #include <stdio.h> void main() { float a[11], *pa; // Array and ptr set. int i; // counter for the loop. pa = a; for (i=0 ; i<=10 ; i++) // the loop itself.
I am trying to create a program that will give me an value for a chosen from the user array ut I believe the program I've made does not recognize the values of the previous arrays. (Here is my program):
#include<stdio.h> int main() { int n; int i; int j; float c; float a[10000];
[Code] ....
There must be problem cause every value I give n(only for n=1 the answer is correct) the result is "a[n] is -inf"
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?
I am trying sort my Calorie array and day array corresponding to each other but how to start i cant grasp the concept for some reason. I want it to sort by calories in descending order.
So instead of this...
Day: Calories:
1 200 2 500 3 400 4 600 5 100
I want this.....
5 100 1 200 3 400 2 500 4 600
#include <cstdlib> #include <iostream> using namespace std; //Prototypes int getDays(int); void getCal(int*,int); float calcSum(float,int*,int);