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


ADVERTISEMENT

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++ :: Print Out The Ratio Max / Min?

Aug 15, 2014

Given three integers, print out the ratio max/min

#include <iostream>
using namespace std;
int main(int x,int y,int z,int max,int min)

[Code].....

My Dev++ App in error

View 1 Replies View Related

C# :: Keep Aspect Ratio When Resize Form

Dec 15, 2014

When I try to resize my form, every time i try to resize it while running, the window blinks between original size and the new size it was given, when i release the mouse it either stay in its new size or shrinks back to its original size, What makes it return to its original size, maybe its something with the form_Resize function..

private bool inForm_Resize = false;
private Size PrevSize;
private void Form1_Resize(object sender, EventArgs e) {
double dRatio = 1.6;
if (!inForm_Resize) {
inForm_Resize = true;

[Code] ....

View 3 Replies View Related

C++ :: How To Compute Financial Ratio With Using Header File

Aug 19, 2013

How to compute financial ratio in C++ with using header file?

Calculate in c++ program with 3 different file. - 2 file (cpp file) - 1 file (header file)

Information:

formula:-
*1.*Current ratio = (current asset / current liabilities)
*2.*Gross margin = (Revenue – Cost of goods sold) / Revenue
*3.*Operating margin= (Operating Income / Revenue)
*4.*Profit margin = (Net Profit / Revenue)
*5.*ROE= (Net Income/Shareholder's Equity)

I want put 5 formula to run the program. How to put 5 formula in the program but run one formula.

EXAMPLE: In the coding, write all financial ratio. When we compile, just asking 1 formula value only. We need to fixed, which formula to run. Just adjust the coding only.

View 7 Replies View Related

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 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++ :: 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++ :: Create Array Of Playing Cards / Assign Values And Suits Then Shuffle The Array

Nov 24, 2014

I got this program to create an array of playing cards and assign the values and suits and shuffle the array. I'm at the point where I need to output the cards but I need to burn the first card by making it output "**" instead of the card. my cards[] is a constant so I can's assign the first card as such.

void showCards(const int cards[], int numCards, bool hideFirstCard) {
if (cards[0]) {
hideFirstCard=true;
cards[0] = '**';
} for(int a = 0; a <= numCards; a++) {
cout >> showCard(cards[a]);
} }

View 1 Replies View Related

C++ :: Accept Integer Array And Its Size As Arguments And Assign Elements Into 2 Dimensional Array

Jan 10, 2015

Write a program using user-defined function which accepts an integer array and its size as arguments and assign the elements into a two dimensional array of integers in the following format: If the array is 1,2,3,4,5,6, the resultant 2D array is

1 2 3 4 5 6
1 2 3 4 5 0
1 2 3 4 0 0
1 2 3 0 0 0
1 2 0 0 0 0
1 0 0 0 0 0

View 1 Replies View Related

C++ :: Write Function That Takes Array And Returns True If All Elements In Array Are Positive

Jan 21, 2013

Write a function that takes an array and returns true if all the elements in the array are positive, otherwise, it returns false.

View 6 Replies View Related

C :: Store Character Array In Reverse Order Then Display Reversed Array

Jun 14, 2013

The program should store a character array in reverse order then display the reversed array. I have also included in the code that will display the actual characters into the array as it loops through. So I know the characters are being stored, but why doesn't it display the entire string when I call it?

Code:
#include<stdio.h>
int main(){
char str[50];
char rev[50];
printf("Enter Desired Text: ");
scanf ("%[^

[Code] ....

Is it just my compiler?

View 5 Replies View Related

C :: Parsing Char Array To Array Of Struct To Process Packets

May 28, 2013

I wrote this simplified version of a program i am writing that parses data in UDP packets. In the process of doing so i pretty much answered all my questions and fix all the problems i was having.

decodeSystemMap function will be in loop, and will proccess packets that have mostly the same data, only a few items will be added or changed or deleted.

whats the best way to check if there are any new, deleted, or removed items in the packet and only modify those?
Is there anything unsafe / dangrous about the way the code is now?

Code:
/* * File: main.c
* Author: david
*
* Created on May 23, 2013, 11:57 AM
*/

#include <stdio.h>
#include <stdlib.h>

[Code] ....

View 4 Replies View Related

C :: How To Make A Function Read From Array A But Put Select Parts In Array B

Jul 30, 2013

im trying to read in 1 array and get 2 as outputs from 3 different functions.my read array is easy enough were im getting confused is how to read that array, separate it and take out only the parts i want and place them into a 2nd, then again a 3rd array.i have the following so far:

Code:

#include<stdlib.h>#include<stdio.h>
#include<unistd.h>
#define SIZE 10
}

[code]....

this compiles without a complaint, but when i go to run it no longer responds after taking the 10th element (well 9th if counting from 0).I think i have the if correct for the even odd section, but when i try to populate B or C array with the output of that if statement from A is were i think things are dying...

View 12 Replies View Related

C++ :: Storing Numbers Into 2D Array - Invalid Types Int For Array Subscript

May 17, 2014

#include <iostream>
#include<fstream>
int decryption(int);
int multiply(int,int[][2]);
using namespace std;
main(){
int n;
ifstream inFile;
inFile.open ("out.txt");

[Code] .....

I was trying to store numbers read from a text file into 2D array but I am getting the error above.here is where the error occurs:

line 33: cout<<m[i][j]<<" ";

View 4 Replies View Related

C++ :: Using Loop To Process Array Of Characters Starting From Beginning Of Array?

May 3, 2014

Assume you want to use a loop to process an array of characters starting from the beginning of the array. You want the loop to stop when you read the null terminator character from the array. Fill in the loop test condition that will make this work correctly.

index = 0;
ch = array[index];
while ( _____________________________)
{
// process the character
index++;
ch = array[index];
}

View 1 Replies View Related

Visual C++ :: Reading Into Array / 2d Array From Mixed Text File?

Jan 18, 2014

I know to read a strings into array and tables.. what is they are mixed up?? strings are just names ( 3 characters) and there are bunch of table.. the max size was set to 60

ex. text file

JES
DAN
JEN
.
.
.
01010101
10010101
RAM
JET
01010010
10100101
.... and so on

should i use a while loop?

View 10 Replies View Related

C++ :: Multidimensional Array - Moving Whole Int Array Row As A Single Unit?

Feb 27, 2013

I have a multidimensional array that runs parallel with a string array

Lincoln 120 300 400
Parks 100 500 250
Shakespeare 0 30 50
Ghandi 250 100 40
Ashe 300 50 175
Rodriguez 87 118 320
Curie 284 0 112

I need to sort this and I know how to do it. But I need to sort it again with the highest value in the first row and keep all information in that row paired with the name . So

Lincoln 120 300 400
Parks 100 500 250

Parks 100 500 250
Lincoln 120 300 400

I need so swap this whole rows. I'm using dynamic array. So my question is Do I have to do a bunch of temps to move them? Or is there a way to move the whole int array row as a single unit?

View 3 Replies View Related

C++ :: Why Can't Static Array Copy Values From Dynamic Array

Mar 13, 2013

But it can the other way around

Code:
static_Array= dynamic_Array;
dynamic_Array = static_Array;

The second statement works and i'm able to print out both arrays with equal values but with the first

[code] static_Array = dynamic_Array;I get incompatible types in assignment of 'int*' to 'int [7]' is the error I get [/code]

View 2 Replies View Related

C :: Print Values Of Array From Function By Passing Array?

Nov 1, 2014

I wanted to print the values of a array from a function by passing the array as well as the number of elements to be read. For a single dimensional array, this is how i have written it. It's pretty straight forward. I want to read 5 elements from the 5th element in the array.

Code:
#include<stdio.h>
void display(int array[],int size) {
int i;

[Code]....

With this code I want to print the five elements from the element present in [0][4].

But shows an error that

Code:
D:BennetCodeblocks CLearning CSingleDimentionalArray.c||In function 'main':|
D:BennetCodeblocks CLearning CSingleDimentionalArray.c|18|warning: passing argument 1 of 'display' from incompatible pointer type [enabled by default]|
D:BennetCodeblocks CLearning CSingleDimentionalArray.c|2|note: expected 'int (*)[10]' but argument is of type 'int *'|
||=== Build finished: 0 error(s), 1 warning(s) (0 minute(s), 0 second(s)) ===|

I know when you pass a array as an argument it gets decomposed into a pointer, but with a multi-dimensional array this is not the case. how this works for mult- dimensional array's?

View 3 Replies View Related

C++ :: Passing 2D Array To A Function Where Size Of Array Is Not Known At Runtime

Jun 27, 2014

I'm wondering if it is possible to pass a 2d array to a function where the size of the array is not known at runtime.

I've tried

function ( array[][6] ) ;

But the size of the array has to be constant so it cannot be declared later.

I've tried using a template but you still have to declare the size of the array at runtime. Is this even possible at all?

The only other way I can think of is using a dynamic 2d array but how to create one and manipulate it.

View 2 Replies View Related







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