C++ :: Computing Net Pay - Too Few Arguments

Apr 13, 2013

double compute_taxes(double gpay) {
double gross;
double td; // to hold the tax deduction
if (gross <= 1000)
td = gross * 0.5;
else if(gross < 1500)
td= gross * 0.6;

[Code] ....

Write the function double compute_npay(double gpay) that receives an employee's gross pay using the value parameter gpay, computes the net pay and returns it. the net pay is the gross pay - the tax deduction. To compute the net pay, it first calls compute_taxes() to compute the tax deduction.

View 4 Replies


ADVERTISEMENT

C :: Computing Ratio With Array?

Feb 10, 2014

What is wrong with this code cause im not getting the correct ratio of total people to cumulative length?

Code:
#include<stdio.h>
#include<stdlib.h>
//define constant variables
#define FIRST_CAR_LENGTH 10
#define NORMAL_CAR_LENGTH 8
#define CAR_CAPACITY 4
int main(void){
//Set up some variable with values that come from input or calculations

[Code].....

View 7 Replies View Related

C/C++ :: Computing Bit Difference Between Two Arrays?

Jul 23, 2014

#include <stdio.h>
#include <stdlib.h>
int b_diff (int, int);

[Code].....

I am trying to take two arrays H[], and V[] and call each element to compute the bit difference(Hamming distance) and return that back to the main function to be used in calculating pixel_phase and pixel_smoothing. I'm getting an error that bit_diff cannot be used as a function and I've tried renaming it but nothing seems to work.

[ int b_diff (int a, int ] is how it should actually look.int b_diff (int a, int is how it should actually look).

View 14 Replies View Related

C :: Program Is Not Computing Averages From Array

Sep 23, 2013

This code is not computing the averages.. I am trying to add up all the values in the array and divide them by the number of addresses in the array

Here is the snippet of what I have do far :

//Run through all possible train combinations

Code] :

for(tl=10; tl<=max_tl; tl+=8) {
n_cars++;
num_trains=(.25*max_track)/tl;
num_people=n_cars*num_trains*4;

[Code] ....

View 10 Replies View Related

C++ :: Computing The Riemann Zeta Function?

Sep 30, 2013

I'm suppose to provide an inner loop that computes the zeta function and the other loop is just press y for to continue, anything else exit.so far i got this:

#include <iostream>
#include <cmath>
#include <stdlib.h>
using namespace std;
int main() {
double x, n,zeta;

[code]....

I can't seem to get the formula right.

View 2 Replies View Related

C++ :: Recursive Function For Computing Total Route

May 11, 2014

How to do recursive function for the following?

RecursiveComputeRouteDistance(p1index,p2index,locations,latitudes,longitudes): recursively computes the total distance between all waypoints (route) using computeDistance function to compute the distance between two adjacent points. You need to recursively compute the distance for the base case(s) and the general case(s).

This is my computeDistance function

int computeDistance(double a1,double b1,double a2,double b2) {
const int R=6378136;
const float Pi =3.14159;
float Dist=0;
Dist= ((Pi*R)/180)* acos((cos(a1)* cos(b1)* cos(a2)* cos(b2)) + (cos(a1) *sin(b1)* cos(a2)*sin(b2)) + (sin(a1)*sin(a2)));
return Dist;
}

View 2 Replies View Related

C/C++ :: Right Triangle Program - Computing Lengths Of Sides

May 5, 2014

I made a simple program to compute the lengths of a triangles sides, but when I enter 30 for angle and 10 for hypotenuse I get the opposite side is -9.880316 and the adjacent is 1.542514.

#include <stdio.h>
#include <math.h>
main() {
float angle;
float hypotenuse;
float adjacent;
float opposite;

[Code] ....

View 2 Replies View Related

C++ :: Finding Pi Through Computing Area Of A Quarter Circle?

May 4, 2015

question: Finding pi through computing area of a quarter circle

my code

PHP Code:

#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main() {
    int sum=0;            
    double PI,h,x;            
 
[Code] .....

View 14 Replies View Related

C :: Verified Code For Computing Fast Furrier Transform Of Image

Jun 9, 2013

i am looking for a verified code in simple c, for generating fft of an input image (.jpg). the output can be a text file including fft coefficients.can you recommend me any source except open-cv?

View 6 Replies View Related

C :: Computing Grades From Input File And Writing To Output File

Aug 31, 2014

One of my class assignments is to create a program that receive a .txt file containing a students name and their grades as follows: John K. 99, 87, 57, 89, 90, 95 Amanda B. Jones 100, 88, 76, 99, 86, 92 etc.. The number of students is unknown until run time. You have to take those grades and average them weighing the first (4) at 10% a piece and the next (2) at 15% each and the final at 30%. Then return an output file with the students name and their letter grade A,B,C,D,F based on their computed score. In addition, on screen it needs to display the average scores for each Q1, Q2, etc. as well as the minimum and maximum for each test on the screen. I am having a hard time in assigning the scores to a variable so that they can then be computed as an average and then used to determine a letter grade. I have begun to write the code and am a bit stuck..here's what I have so far:

Code:
//
// main.c
// Final Exam
//

[Code].....

The problem I'm having now is how to go about passing the grades to the function computeGrade and then compute the average and return that to the function.

View 4 Replies View Related

C++ :: Function Does Not Take 3 Arguments

Apr 27, 2013

I am doing a problem where I need to use arrays of string objects that hold 5 student names, an array of one character to hold the five students' letter grades and five arrays of doubles to hold each student's set of test scores and average score.

When I try to run it, I get these five errors.

error C2660: 'getTestScore' : function does not take 3 arguments : line 39
error C2660: 'getTestScore' : function does not take 3 arguments : line 45
error C2660: 'getTestScore' : function does not take 3 arguments : line 51
error C2660: 'getTestScore' : function does not take 3 arguments : line 57
error C2660: 'getTestScore' : function does not take 3 arguments : line 63

what is wrong.

Here's my code.

View 4 Replies View Related

C++ :: Templates Without Arguments

Jan 22, 2013

Some reading through C++ code I come across template deceleration without any type , I have tested the code it compiles too

Code:
template<>
class abc {
}
similarly template usage

Code:
abc<> a;

example of such usage can be found here [URL] ....

View 5 Replies View Related

C :: Using Or Inside Case Arguments

Nov 6, 2013

I would like to choose same case for multiple switch conditions.

For example:
Code: switch(choice) //''if choice ==0 or choice ==1, chose same case''
{
case (0 || 1):
{
//execute steps
}
break;
default:
{
//execute steps
}
break;
}

The '||' inside case does not have the desired effect (although it compiles fine). How can I do it without using if-else statements.

View 1 Replies View Related

C :: Passing Arguments To Functions

Feb 4, 2013

Having a little trouble passing arguments to functions.

I wrote this simple program to get the hang of it but I'm quite stuck. I'm sure you will be able to get at what i want the program to do...

Code:
#include <conio.h>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <windows.h>

void menu(int HP,int Gold,int Armour);

[Code] ....

View 3 Replies View Related

C :: Arguments When Declaring A Function?

Jun 5, 2013

I am a bit confused about how specific one must be with arguments when declaring a function. I'll show you two functions from the book I'm using to learn C to show you what I mean.

Example 1 (greatest common denominator function):

Code:
void gcd (int u, int v) {
int temp;
printf ( "

[Code] ....

So in that function, there are exactly two arguments, because that's how many arguments the algorithm to find the gcd takes. No problem there, makes sense to me. Then further in the chapter on functions I run into this,

Example 2 (square root function):

Code:
float absoluteValue (float x) {
if ( x < 0 )
x = -x;
return x;

[Code] ....

In this second example, we have a square root function that is preceded by an absolute value function. The absolute value function has the one argument, "float x", however when this function is called within the square root function, the arguments "guess * guess * -x" are passed to it. I'm confused how this absolute value function is working with all of that inside it, when it was originally declared with just "x." The only possibility I can think of is that this expression is treated as a single unit, but I'm not sure.

View 2 Replies View Related

C :: Pointers As Arguments In Functions

Aug 23, 2013

I'm having some problems with a function. The function is supposed to find the two largest values in an array.

Code:

void find_two_largest( const int *a, int n, int *largest, int *second_largest){
largest = a;
int temp;
second_largest = a;
for ( int i = 1; i < n; i++){
if (*(a + i) > *largest){
temp = *largest;

[Code]....

I don't see any mistake with the code of the function, but when I try to call it inside my program it only returns 0 for both largest and second_largest.

Code:

int *find_middle( int *a, int n);
void find_two_largest(const int *a, int n, int *largest, int *second_largest);
int main()
{
int n;

[Code]...

Do I have to declare the variables largest and second_largest as normal integer variables and then pass their addresses as arguments to find_largest or is that incorrect?

View 10 Replies View Related

C :: Function With Multiple Arguments

Jan 15, 2015

I am actually developing an nginx module in C.I am not to bad in C, but i got a big problem to pass argument to a vadiadic function.This function look like the well good old printf, but you put a buffer as first argument, the last address to stop to put data as second argument (in my case it is the last adress of disponible memory), a string that look like one in printf, an the other argument after.Here is the problem, the 4th last argument does not have the good value. In fact, It seem to be random value from memory. I Use gcc (Debian 4.9.1-19) 4.9.1.

Code:

/* ngx_html_log.h */
#ifndef NGX_HTML_LOG_H
#define NGX_HTML_LOG_H
#include <ngx_vasm.h>
}

[code]...

View 3 Replies View Related

C :: Command Line Arguments

Jul 28, 2013

I am using visual studio 2010 c++ express for C/C++ programming but is novice here to take command line arguments..i did went to project->properties->debugging and specified there the command line arguments but it didnt work..i think i need to know the format to enter the arguments.

View 9 Replies View Related

C :: Passing Arguments To Main

Feb 10, 2015

I have a 1wire program from maxim running in visual studio. There is this argument in the main function that requires the com port to be specified the command line. If I do pass it as "COM1" the program works as expected.

I don't want to depend on having to pass "COM1" in the command line and into main. I've tried creating a string for COM1 and passing it right into the if function but it doesn't work.

Code:
int main(int argc, char **argv) {
int len, addr, page, answer, i;
int done = FALSE;
SMALLINT bank = 1;
uchar data[552];

[Code] .....

View 1 Replies View Related

C :: How To Create Default Arguments

Oct 20, 2013

How to create default arguments in C? Is there any way to make default arguments ( i mean any alternative for them).

View 5 Replies View Related

C :: Handle Cmd Line Arguments?

Jul 30, 2013

How to handle cmd line argument in c.

View 5 Replies View Related

C++ :: Function With Template Arguments

May 26, 2013

I'm trying to create a callback wrapper for pointers to member functions of any class by using templates, std::function and std::bind. This will be used to send incoming sf::Event's to classes who register callbacks with an event manager. I based my code off of the example on this page: URL.....Here's what I have:

class EventCallback
{
std::function<bool(const sf::Event&)> func;

public:
template<typename T>
EventCallback(T* object, bool(T::*func)(const sf::Event&)) { func = std::bind(func, object, std::placeholders::_1); }
bool run(const sf::Event& evt) { return func(evt); }
};

[code]....

View 4 Replies View Related

C++ :: Default Arguments And Omitting Only Some Of Them?

Apr 7, 2014

I am trying to figure out what's the best way to accomplish something like this:

void function(t1 a=0,t2 b=0){/*...*/};
t2 value;
function(value);

That would throw a compile error, since the first argument that is being passed to the function (value) is considered the first argument in the declaration (a), which is of type t1. So, is there a way to force my function to consider value as the second argument instead of the first one? I am aware that this could be done using overloading, but the larger the amount of arguments, the larger amount of possibilities, so it might end up with a huge list of overloads. The best case scenario would be being able to set things like:

void function(t1 a=16,t1 b=0,t2 c=1){/*body*/};
function(b=3,a=0);
but I'm not aware of such feature in C++.

Would it be possible to design some sort of macro system to take care of this?

View 10 Replies View Related

C/C++ :: Pointer As Function Arguments

Dec 26, 2014

How this code work bcoz when pointer variable assigned in called function and how different values get as resultant output, ans 2 97 for below code. How the code wil execute so that i can validate ans

#include <stdio.h>
int main() {
int i = 97, *p = &i;
foo(&i);
printf("%d ", *p);

[Code] ....

View 6 Replies View Related

C++ :: Passing Arguments By Const

Oct 7, 2014

I know that passing arguments by const instead of value is more efficient and allows us to avoid allocating a temporary local variable of the argument type. But is this always true? Or are there some cases when calling functions with constant arguments should be avoided? If so, is passing by pointer the most efficient way?

View 6 Replies View Related

C++ :: Compiler Command Line Arguments

Jun 15, 2013

I have found this C++ online compiler (to use when I am at work): Compile and Execute C++ online

When you write and compile a program, on the right side (the "output" side), you can read this command line arguments:

$ g++ main.cpp -o demo -lm -pthread -lgmpxx -lreadline 2>&1

What is the meaning of the following arguments? -lm [link the math header file, right?]

-pthread
-lgmpxx
-lreadline

Any book (ebook, tutorial, printed book, whatever) where I can find all (absolutely all) these and other possible arguments?

View 2 Replies View Related







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