C++ :: Void Function To Calculate Payroll

Dec 9, 2014

The purpose of this code is to calculate a pagecheck for intered hours and overtime for any hours over 40! This is what I have so far!

#include<iostream>
using namespace std;
void Amount (int hours, int wage, int sum);
void printCheck(int sum);
int main()

[code]....

View 1 Replies


ADVERTISEMENT

C++ :: Program To Calculate Company Weekly Payroll - Calling Functions?

Jun 9, 2014

This program in not completed. I am creating a large program in order to calculate a company's weekly payroll. For now I am filling in the separate functions piece by piece before the rest of the program is completed.

Right now I am trying to use separate functions to call other functions. I need to ask the user for the file name and then open the file. I am no longer getting any compiler errors however when I run the program all it displays is "Welcome."

So it's not actually calling the NameTheFile function and the OpenTheFile function. It just says "Welcome" and then closes down. Why is it doing this?

/*Program to determine company's weekly payroll*/

#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void NametheFile() {

ifstream inputFile;

[Code] ....

View 1 Replies View Related

C++ :: Calculate Angle Value In Form Of Trigonometric Functions - Loops And Void

Jul 24, 2013

This is an assignment which the purpose is to calculate an angle value in form of trigonometric functions. These are the codes that I've wrote so far.

#include <iostream>
#include <cstdlib>
using namespace std;
void menu(double &value) {
system("cls");
cout<<"*****Trigonometry Program*****"<<endl;

[Code] ....

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.

View 2 Replies View Related

C++ :: Pass 2 Arrays Into Void Function And Return Values To One Function?

Feb 12, 2014

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.

View 6 Replies View Related

C++ :: Void As Function Argument

Mar 24, 2014

I was reading about void as function argument, but I did not fully understand it's meaning in C.

In C++
void foo(void) {}
and
void foo() {}

are the same. It means no arguments for foo function. But in C it's different. First function means the same as in C++, but second means

In C, an empty parameter list means that the number and type of the function arguments are unknown. But if it is unknown you can't use this arguments if user specifies same. Because here are no variables to store them. So doesn't result are the some? You do not get any arguments. O do I can get this arguments from some hidden variable?

For example.

void foo() {
printf("%d", var);
}
foo(5);

It is very unclear for me. Do this apply to main function too?

int main(void)
int main()

or can I use arguments given to int main() like given to int main(int argc, char* argv[])

View 4 Replies View Related

C++ :: Using Break In Void Function That Does Not Contain A Loop

Jan 14, 2015

I need this break in my main function, but I'm not allowed to put it in void since void is not located in a loop. How can I solve this?

Code:
#include <iostream>#include <string>
using namespace std;
void login(string x, string y);
string username;
string password;
string x;
string y;

[Code] ....

View 6 Replies View Related

C++ :: Multiplication Table In A Void Function?

Jan 20, 2015

I wanted to make a multiplication table.

Here's the code:

#include<iostream>
#include<conio.h>
using namespace std;
void initArray(int arg1[50][50], int r, int c) {
int val=1;
for(int row=0; row<r; row++) {

[code]....

I want the output to be like this:

1 2 3
2 4 6
3 6 9

If the user inputs 3 rows and 3 columns.

View 5 Replies View Related

C :: Program To Use Void Pointers In A Function

May 14, 2014

As part of my ongoing c programming education, I have written a program to use void pointers in a function,

Code:

#include <stdio.h>
#define MAX_NUMBERS 10
size_t size(void *object);
int main(void) {
}

[code]....

Now I think that the result 4 is the size of the pointer, so I'm confussed as why it doesn't give me the same result as 40.

View 2 Replies View Related

C++ :: If Statement - Void Function Not Calling

Nov 2, 2013

I've been trying to get my program to call void functions with an if statement, but when i run my program and try to call one of the functions "worst case, best case, or random case" it doesn't get called. It just prompts the original menu.

#include<iostream>
#include<fstream>
using namespace std;
void bubbleSort();
void selectionSort();

[Code] .....

View 1 Replies View Related

C++ :: Opening A File In Void Function

Feb 26, 2013

how do you open a file inside of a void function

this is the code i have

#include <iostream>
#include <fstream>
#include <sstream>

[Code]....

View 6 Replies View Related

C++ :: How To Pass Char To Function Void

Jun 1, 2013

How to pass the char something[8][8] for example to function void ( char pass.....)???

View 7 Replies View Related

C++ :: How To Pass A Void Function As Parameter

Oct 20, 2013

How can I pass a function as a parameter? I have a class that I'm trying to reuse and one of the methods in this class need to take three parameters, two ints and a function. In other words I want to be able to call a custom function every time this method is invoked when used in other classes. The function I want to call will not return any values, its a void function.

In my Class:

void Utility::someFunction(int var1, int var2, void customFunction) {
int num1 = var1;
int num2 = var2;

[Code] .....

View 9 Replies View Related

C++ :: Using A Void Function For Data Input?

Feb 20, 2014

Modifying this program to Create a function that has the following prototype: void getInputChar(string, char &);.

The function should display the string on the screen and then use cin to read a char from the keyboard.

#include <iostream>
using namespace std;
bool ignoreCaseCompare (char, char);

[Code].....

View 1 Replies View Related

C/C++ :: Find Max And Min Value In Void Function Using Pointers

Aug 31, 2014

I'm having issues with pointers and relationship operators in C.

I need to find a max and min value in a void function using pointers. max and min would work if they had values. mul works, because you can just do math operations with pointers.

There are 0 errors and warnings; but max and min are never going to work as is.

Clearly I'm missing something.

#include <stdio.h>
#include <stdlib.h>
void max(int *a, int *b, int *c, int *d, int *result);
void min(int *a, int *b, int *c, int *d, int *result);
void mul(int *a, int *b, int *c, int *d, int *result);
int main()

[Code]...

Your job will be to create a program that uses pointers. Your output must be done in the main function and the calculations MUST be done in the three functions. Therefore you MUST use pointers correctly.

You must declare and implement the following 3 functions. Below are the three prototypes that you must use in this program.

void max(int *a, int *b, int *c, int *d, int *result);
void min(int *a, int *b, int *c, int *d, int *result);
void mul(int *a, int *b, int *c, int *d, int *result);

The functions have the following meaning:

max
finds the max value of a,b,c,d and stores the largest value in result.
min
finds the min value of a,b,c,d and stores the largest value in result.
mul
multiplies a * b * c and divides by d. Stores that value in result.

Below is an example input/output. This input will be read in via the keyboard (use scanf).

input
output (note that user input is shown in bold)
1 2 3 4
Enter the 4 numbers: 1 2 3 4
The max is 4. The min is 1. (a * b * c) / d = 1
100 3 201 103
Enter the 4 numbers: 100 3 201 103
The max is 201. The min is 3. (a * b * c) / d = 585

Your output MUST match exactly the output below for the input from above. Your program must compile, failure to do so will result in 0 points. */

View 9 Replies View Related

C++ :: Void Pointer Argument In A Function?

Jun 11, 2014

Why does the following code compile and execute without any error? I mean, the function compareid should get 2 arguments so why does the compiler not complaining, is it because of the type of arguments?

Code:
#include <stdio.h>
int compareid(void* info, int value); // ansi declaration
int compareid(void* info, int value)

[Code] .....

View 5 Replies View Related

C++ :: Passing Data Through A Void Function

Mar 11, 2013

I am new to C++ ... My question is if I were to pass some data or values from the main() function through a void function (which main purpose is to display the data in a certain manner); how should one go about doing so?

For instance:

Code:
// example.cpp -- poorly written, just trying to learn
#include <iostream>
void format() {
using namespace std;
cout << "Time: " << min << hrs << endl;

[Code] .....

Obviously this is really poorly written, and confusing for the user. My main goal is to learn how to pass through values to a void function.

Also a bit off-topic, but is there a downside to place "using namespace std;" outside a function say if out of 100 functions only 10 of them use it? Would it make the program slower/unstable in any way or is this something one could do without any downsides?

View 3 Replies View Related

C++ :: Changing Values In A Matrix Using Void Function

Jun 29, 2013

I have the following void function devised to assign "+1" or "-1" to each element of a matrix at random. While the function does what I want, when I print the values of the matrix all are set to zero:

#include <vector>
#include "aRand.h"
#include <iostream>
void initConfig(std::vector<std::vector<int> > premat, int nL, int nN) {
int * pnRand;
pnRand = 0;

[Code]...

The function pnRand_plus returns a pointer to an array of random numbers from 1 to 100, with seed time(NULL) + i. The values printed in main are zero, despite the values printed during the function run are fine (-1s and +1s).

View 2 Replies View Related

C++ :: Void Triangle - Print Class Function

Sep 1, 2013

//Point.cpp
#include "Point.h"
#include <iostream>
#include <cmath>
using namespace std;

Point::Point() { //Initialise the point to the origin.

[Code] ....

void Triangle::print() { //print out the Triangle with the format "( (x1, y1), (x2, y2), (x3, y3) )"

How do I accomplish this? When i test with cout << _point1.print(), there's an error:

[Error] no match for 'operator<<' in 'std::cout << ((Triangle*)this)->Triangle::_point1.Point::print()'

View 4 Replies View Related

C/C++ :: Basic Console Calculator - Void Function Getting Ignored?

Jun 16, 2014

I made a basic console calculator in C++ using the Code::Blocks IDE and using the GNU GCC compiler. The problem in my code is my void function called 'operate' is getting ignored by not showing up in the console. After the first if statement I added a user input by saying Y for yes or N for no. Another if statement inside the first one shows if you type either 'Y' or 'y' it will execute the 'operate' function which will restart the calculator by having the same selection menu as in the int main function. When I call the function it does not show up in the console but just ends the program.

Here is my code:

#include <iostream>
#include <cstdlib>
#include <string>
using namespace std;
int input,input2, numAdd, numAdd2, numSub, numSub2, numMult, numMult2, numDiv, numDiv2;
void operate() {
cout << "Select a operator." << endl;

[code].....

View 2 Replies View Related

C/C++ :: Warning / Control Reaches End Of Non-void Function

Apr 25, 2013

I keep getting 'warning: control reaches end of non-void function' with this code:

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {  
 if (section ==0)  {
  return [comparativeList count];
 }  
 if (section==1)  {
  return [generalList count];
 }  
 if (section==2) {  
  return [contactList count];

How can I get rid of this warning?

View 3 Replies View Related

C++ :: How To Output Void Function On A Text File

Feb 12, 2013

So I am writing this code that analyzes a file called "analysis.txt" and prints out in an ouput file (called "report.txt") the results of the analysis, i.e.,(the frequency of all alphabet letters present in the file).

I am having trouble with outputing on the file2.

here is what I have:

Code:

#include<iostream>
#include<fstream>
using namespace std;
ifstream file1;

[Code]....

I tried to lose the "<<" after the file 2, but it's still giving me an error. how to output a void function on a text file?

View 14 Replies View Related

C++ :: Inputting TXT File Into 2 Parallel Arrays Via Void Function

Nov 10, 2014

I have a .txt file that I need to input into two parallel arrays. The first array needs to be on dimension and the second needs to be two dimensions.

This is a sample from the .txt file:

Australia62.762.163.359.7
Austria052.853.154.6
Belgium30.430.327.525.3
Canada61.356.257.754.5
Chile026.425.431.1
CzechRepublic038.327.325.2
Denmark65.067.162.355.0
Estonia51.732.929.834.3
Finland55.242.942.143.3
France35.728.330.228.8
Germany56.447.242.646.6
Greece30.326.925.013.1
Hungary032.521.818.6
Iceland068.271.666.0

this is what I have for code so far:

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>

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.

View 10 Replies View Related

C++ :: Return Struct Pointer From A Void Function And Print

Mar 17, 2013

i need to return a struct pointer dynamically allocated inside a function call void function() which is done using 'out parameters' in following code

struct my_struct {
int x;
} void my_function( my_struct** result ) {
my_struct* x = new my_struct{ 10 };
//...
*result = x;
}

Now i have a doubt, so if i want to print the return value from struct pointer, should i need to print it in the void function() or in the caller the function...

View 3 Replies View Related

C++ :: Defining Classes And Using Them Inside Void Main Function

May 18, 2013

This is a program I developed in which we had to define a class named BOOK with the data members and member functions as shown in the program..We have to:

(i) Make the user enter the values in the array BOOK.
(ii) Display the details that the user entered.
(iii) Search for a book from the array upon its Bno and display its details.
(iv) Search for a book from the array upon its Bname and display its details.

PROGRAM:

#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
class BOOK {
private:
int Bno;
char Bname[20];

[Code] .....

But while running it the compiler gives the errors as:

Line 43 to 48: Illegal character '' (0x5c)
Line 69: Undefined symbol 'Display'
Line 88: 'BOOK::Bno' is not accessible.
Line 89:'BOOK::Bname' is not accessible.
Line 90:'BOOK::Author' is not accesible.
Line 91:'BOOK::Price' is not accesible.
Line 108:'BOOK::Bno' is not accessible.
Line 109:'BOOK::Bname' is not accessible.
Line 110:'BOOK::Author' is not accesible.
Line 111:'BOOK::Price' is not accesible.
from 43 to 48..the line feed was also used at many other places but there it was not given as an error so why here?
Line 69: I defined the Display() function outside the class since it contained control structures, so what's the error then?

About the lines the rest of the error( the "not accessible" ones) I know these data members are not accessible because they are in private visibility mode. But then how to make them accessible? (Without putting them in public because it was a part of the question to create the data members in private).

View 1 Replies View Related

C/C++ :: Why Do Void Function Pointers EXECUTE Arrays Of Hexcode

Dec 23, 2012

I know how to use functions pointers in C and C++ and I know if you have something like

char buf[] = {
0x48, 0xb8, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x48, 0xbf, 0x02, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x0f, 0x05
};
((void (*) (void))buf)();

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?

View 7 Replies View Related

C++ ::  Why Every First Function Of Each File Get Error - Multiple Definition Of Void Pointer

May 6, 2014

I declared all functions in header file, such as:

bool readCase();

bool meshing();
bool readMesh();

bool calculateFlowfield();
bool readFlowfield();

bool calculateEvaporation();

And then I define them in separated .cpp files, each .cpp file include the header, but I got multiple definition error, why?

Even the int main() function, which only decalred and defined once got this error, why?

View 14 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved