I want to write a code that gets three values from the user and puts them into three arrays. When the user enters -999, I want to print out a chart showing all the values they put in. This is what I have so far but it wont build. It tells me std::string is requested, but I'm not sure where to put it, and printArrays is declared void. How can I fix this?
#include <iostream>
#include <string>
using namespace std;
const int ARSIZE = 400;
void printArrays (string reportTitle, int levelsArray[], int scoresArray[], int starsArray[], int i);
My assignment is to write a program using VOID FUNCTIONS WITH AN ARGUMENT.
*I need one non-void function with an argument to generate the first 15 numbers greater than 500, another non-void function with an argument to generate the first 15 perfect squares that are greater than 500. Last, they need to be in columns next to each other.* also i cant use x,y, coordinates to align them. i must create a for loop with the
These are some notes from examples in the class. i just don't know how to do it with non void functions with an argument.
1) This first function initializes an array of 30 components so that the first 15 components are equal to the square of the index value and the last 15 components are equal to the index value multiplied by 3.
2) The second function processes the array by finding the sum of the first 15 components and the sum of the last 15 components to determine which sum is bigger. The output to the screen should do the following:
a)State “The sum of the first 15 components is:” and then show the sum. b)State “The sum of the last 15 components is:” and then show the sum. c)State which of the two resulted in the greater sum or if the two sums were equal.
Function: The program uses two subroutines. One to initialize an array and the other to process the array and print to screen results:
#include <iostream> #include <iomanip> // Include any other header files you may need.
const int ARRAY_SIZE = 30; void initialize ( double list[], int index ); void square ( double list[], int index ); void threeTimes ( double list[], int index ); void output ( const double list[], int index );
At first i had my int variables in global scope however i cant do the so im trying to pass my variables from my main to the void functions but cant.....
I missed last class on doing void functions because I got sick and im completely lost! ive being using the texts book example for a reference but its not running !
The output should look similar to this:
how much was your shirt? 20 shirt 20.00 tax =1.20 the total 21.20
Code:
include <iostream> #include <iomanip> using namespace std;
This code i made is a cent converter from 5 to 95 cents. The problem i'm receiving is when the 'cents' function is sent back to the 'main' function it only prints one line. It seems to just print the first if construct that complies with the statement. Is there anyway i can have this function print multiple cent values? For example if 60 cents was entered it would only print '50c', and i want it to print '50c' and '10c' instead.
Code:
#include <stdio.h> int x; void check(int x) { if( x < 5) printf("Less then 5 cannot be calculated "); else if(x > 95)
I have completed the codes for the interface part. Before I proceed with the formula for the trigonometric functions, I would like to make sure the program is Error-free, which if there is accidental invalid input from the user, the program would the user to enter another input until it is a valid response.
The only problem I have encountered for this matter was in menu(value)
If I enter an integer, the program will proceed without error. However, If I enter a character, the program will slip into an endless loop which constantly shows this
*****Trigonometry Program***** Please enter an angle value => Is the angle in Degree or Radian? Type D if it is in Degree Type R if it is in Radian Your response=> 0 //my initial input for value
Do you want to continue? Type Y to continue Type any other key to stop Your response =>
Where is the source of the problem? I'm pretty sure it's the loop, but I don't know what to do.
using namespace std; const int SIZE = 40; const int COLUMN = 5; void getData(ifstream& inf, string n[], double tstData[][COLUMN], int count);
[Code] .....
when I compile and run the code and have it display it does not read the first item into the 1-d array, instead it appears to read the 4th number from the left into the 1-d array and then into the second spot in the 2-d array, then again in its proper place and finally it has this number repeating through the rest of the arrays:
-92559631349317830000000000000000000000000000000000000000000.00 followed by the number 59.7 from the .txt and the long number again.
That this will execute those binary instructions in hexadecimal notation BUT WHY? I don't get why that works since that's an array of data not a function?
I'm trying to pass 2 arrays into a void funtion, and return values to one function.
this is the the program I'm working with, after I'm done I have to split it into 3 files, a header, a main, and a separate cpp file for the functions to live in.
#include <iostream> using namespace std; void processArrary(int numberCount[], int Numbers[], int intnumberSize, int numberCountSize); int main() { int Scores[26] = {76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200, 87, 35, 157, 189}; int numberCount[8] = { 0 };
[code]...
The goal of this program is to separate and count the groups of numbers then output the amount of numbers in each group. Near as I can tell, everthing should work, but I'm getting all zeros to be displayed in each group.
You have to write a single C program that creates a one dimensional array of size MAX(to be declared as a declarative constant using directive #define MAX 10), initializes its elements with a given value using the function InitArray, then populate the array with some random numbers between 1 and MAX inclusive, and finally search the array for certain keys.
The structure for this C program is as follows:
int main() { //array A to be locally declared here int size = MAX; }
i have a program that works, but now I am trying to get function1() to work. What it has to do is bring in the array and populate it with random letters. I don't know much about functions.
Code:
#include<stdio.h> #include<stdlib.h> #include<time.h> #define maxrow 20 //defines maxrow as a constant of 20 #define maxcol 30 //defines maxcol as a constant of 30 }
I'm truing to write a function that gets an array of arrays, and returns an array. I placed the code I'm using below, but I'm getting all kinds of errors. How is the right way to do this?
I can write code that can sort arrays with Bubble, Selection and Insertion algorithms but I'm not sure how to have them be called and return a value 3 different times with 3 different sizes. For example, I need it to return 10, 100 and 1000 but I'm stuck.
#include <stdio.h> void selectionSort (int list[], int last); int main()
I am having a problem with my program to calculate the GPA of a student. The problem that I am having is that I am not able to get my Total Point Value to display the sum of the two arrays. The multiplication for the array is correct and will display correctly, but instead of putting the total into the accumulator it will display the totals in a column. I have tried moving the coding for the calculation out of the loop that converts the letter grade into a point value,and placing it in it's own loop, but I still get the same display output. Below is the code that I have so far. I still have a few elements to add to the code, but they will be easy once I get this display to work right.
#include <iostream> #include <iomanip> #include <fstream> using namespace std; // Global const // prototype int main () { // Varialbes, Arrays
I'm trying to code one of the problems but it really is hard to catch errors for a novice like me at first.
I have to Write a single C function for computing the histogram of a list of nonnegative integers into 4 bins.
The main() function first initializes a positive integer array called List of size N, takes 3 inputs from the user A, B, C (assume 0 < A < B < C), and declares a second integer array Bin[4].
The doBinning function should count the number of elements of List in the interval [0, A) and store it in Bin[0], count of [A, B) in Bin[1], count of elements in [B,C) in Bin[2], and the number of elements >= C in Bin[3]
Code: #include <stdio.h> #define N 10 #define M 4 int *doBinning (int source[], int dest[], int a, int b, int c); int main (){
[Code] ....
Somehow I keep getting error from ptr = doBinning(List[], Bins[]. What am I doing wrong? Code might contain some errors.
the book I learn from gave a task to write a program which gets a matrix , and we have to write a function that switches 2 columns or rows the user inputs .as far as I know a function can not change variables in the main function without using pointers .so , theoretically, can a function described here can be written without using pointers ? as far as I tried - it can not.
I wrote a fuction in C with the prototype 'void raisePowerOf2(int array[],int pow);'
If someone want to find the value of 2^456 ,just have to invoke this function 456 as the value for pow and int array with 2 elements :1 & -1 as the argument for the array.(There I used -1 to denote the end of the array.)
But it seems that this function doesn't give the exact answer
And I tried this from java also,with the same implementation.It produced the answer precisely .
I tried for hours, but unable to detect reasons why this code blok in C doesn't work properly
This is the code in c
Code:
#include<stdio.h> void raisePowerOf2(int array[],int pow); int main(){ int a[2]={1,-1}; raisePowerOf2(a,5); return 0; } void raisePowerOf2(int array[],int pow){
[Code]...
This is the code in java....
Code:
public class NewClass4 { void raisePowerOf2(int array[],int pow){ final int len=array.length; int store[]=new int[len+1]; int qtnt=0; for(int i=len-1;i>=0;i--){ store[i+1]=(array[i]*2)%10+qtnt; qtnt=(array[i]*2)/10;
i'm facing some problems with the array, as I have my .h and .cpp files so do i declare them as per norm of how we usually declare a function?
pointtwod.h class PointTwoD { private: int xcord,ycord; float civIndex; LocationData locationdata;
[Code] ....
when i compile the error message i get was even when i i put in int xord[]; in my PointTwoD.h file:
PointTwoDImp.cpp:99:6: error: prototype for 'void PointTwoD::storedata(int*,int*,float*) does not match any in class 'PointTwoD'
PointTwoD.h:48:8: error: candidate is: void PointTwoD::storedata(int, int, float)
PointTwoDImp.cpp: 135:22: error: 'xord' was not declared in this scope PointTwoDImp.cpp: 135:27: expected primary-expression before ']' token PointTwoDImp.cpp: 135:30: error: 'yord' was not declared in this scope PointTwoDImp.cpp: 135:35: expected primary-expression before ']' token PointTwoDImp.cpp: 135:38: error: 'civ' was not declared in this scope PointTwoDImp.cpp: 135:42: expected primary-expression before ']' token
Description: Use functions and structures to simulate storage in a warehouse
*/ #include <cstdlib> #include<iostream> #include<cmath> #include<iomanip> #include<string> using namespace std; struct Bin {std::string name; int Quantity;}; //create a structure for "Bin"
[code].....
I keep getting a linker error on every function. what am I doing wrong?
If someone want to find the value of 2^456 ,just have to invoke this function 456 as the value for pow and int array with 2 elements :1 & -1 as the argument for the array.(There I used -1 to denote the end of the array.)
But it seems that this function doesn't give the exact answer
And I tried this from java also,with the same implementation.It produced the answer precisely .
I tried for hours, but unable to detect reasons why this code blok in C doesn't work properly .
This is the code in c
#include<stdio.h> void raisePowerOf2(int array[],int pow); int main(){ int a[2]={1,-1}; raisePowerOf2(a,5); return 0; } void raisePowerOf2(int array[],int pow){
SO Im supposed to write a program that uses arrays to calculate the sum and display it. I keep getting the error that says the sum has to be initialized.
#include <iostream> using namespace std; //Function prototype int sumArray(int); const int NUM_ELEMENTS = 5;