C++ :: Program To Calculate BMI

Oct 7, 2013

I'm trying to successfully run a program that calculates your BMI but, although it runs, it is not giving the the correct math. Instead, it gives me the number i've submitted as my weight as an answer. I'm using Visual Studio 2008 and the formula: weight / (height/100)*2

Here is my code

#include <iostream>
#include <cmath>
using namespace std;
int main() {
int weight;
int height;
double BMI;

[Code] ....

View 2 Replies


ADVERTISEMENT

C++ :: Program To Calculate Fractions?

Oct 24, 2013

I need to write a program that can calculate fractions.

View 2 Replies View Related

C++ :: Program That Calculate Discounts

Nov 8, 2013

So my midterm exam for programming is done. My program didn't run. Tried rewriting it once I got home. I am still getting an error that the program could not be run. Also, we weren't allowed to use the internet. So I didn't know how to calculate for the discounted rate.

I am using Microsoft Visual Studio 2010.

Given problem:

ABC Hotel offers 5-10% discounts depending on how much money has the user spent. If item purchase is lesser than 1000php (1USD is 43.19PHP) 5% discount is availed. Greater than 1000php then 10% discount is availed. Total price and discounted price should be displayed.

#include<iostream>
using namespace std;
main() {
float a,b,c,d,e,f,g,h,i,j,total,discounted_price;
cout<<"Please input price of first 1st item: ";

[Code] .....

View 1 Replies View Related

C :: Calculate Offset Of Simple Program

Sep 28, 2013

I would to learn how could i calculate the offset of simple c program?

Lets say that I have that simple program:

Code:
#include <stdio.h>
int main() {
int x=1;
printf("x = %d", x);
return 0;
}

View 9 Replies View Related

C :: How To Write A Program That Will Calculate Stress

Feb 7, 2013

I recently signed up for ES201 class and am confused with how to compile a program in the C language that will convert ACT scores to SAT scores.

View 5 Replies View Related

C :: Program That Will Calculate Strain Of Object

Feb 7, 2013

The equation for strain is:

delta(x)/x_0
delta(x) is the change in length of the rod(final length - initial length) x_0 is the original length of the rod

I'm trying to figure out how to write a program that will calculate the strain of an object, given its initial length and final length.

View 2 Replies View Related

C :: Program To Calculate Difference In Time?

Nov 6, 2014

i writing a code which will calculate the difference between time_in and time out. Can i use a 2 dimensional array for example

int time_in[hours][minutes]
int time_out[hours[minutes]

View 3 Replies View Related

C++ :: Program To Calculate How Many X Or / And Y From Specific Range

Nov 7, 2013

X and Y are numbers

For example: how many 2 or/and 5 are inside range of 0 to 30.
for or: there are 8 (2,5,12,15,22,25)
for and: there is only one (25).

View 1 Replies View Related

C++ :: Program That Will Calculate Minimal Polynomial?

Apr 20, 2013

I need to make a program that will calculate minimal polynomial of the nxn matrix.

View 1 Replies View Related

C++ :: Program To Calculate Adjacent Triplets?

Apr 10, 2014

I have this program that calculates adjacent pairs. My question is how can I modify it to calculate adjacent triplets?

//Include statements.

#include <cstdlib>
#include <iostream>
#include <math.h>

//Standard namespace.
using namespace std;

void input (int array[20]); //Used when user inputs the numbers.
void calculate(int array[20], int *pairs); //Used to calculate the matches.
void output(int *pairs); //Used to output the number of pairs.

[Code] ....

View 11 Replies View Related

C++ :: Writing A Program To Calculate Grades

Apr 22, 2014

Writing a program to calculate grades... My algorithm is long, so I only posted the part that gives me trouble. When classes== 1,2,4, or 5, the program runs fine. but it terminates when classes == 3.

if (classes==3) {
do {
cout<<"Enter the Letter grade for 1st class. (USE CAPS)"<<endl;
cin>>grade1;

[Code].....

View 3 Replies View Related

C/C++ :: Program To Calculate Inverse Of Matrix

Apr 3, 2014

I write this code for Inverse of matrix in C language . But there is error in determinant function that say "can not convert 'float' to 'float(*)[20]' for argument '1' to 'float determinant(float(*)[20])' " ....

/* a program to calculate inverse of matrix (n*n)*/
//actually one of the way to calculate inverse of matrix is : A^(-1) = 1/|A| * C(t)
that A is matrix and c(t) is taranahade A

#include <stdio.h>;
#include <conio.h>;
#include <string.h>;
#include <stdlib.h>;
const int max=20;
int i , j , n , k , size=0 , row , column ;
float num , det=0 , inverse_matrix[max][max] , matrix[max][max] , new_mat[max][max] , m_minor[max][max] , m_Transpose[max][max];

[Code] .....

View 14 Replies View Related

C++ :: How To Write A Program To Calculate Pi To N Number Of Places

Aug 13, 2014

I assume floating point numbers in C++ have a default maximum of 5 decimal places. You can use setprecision() but is this limitless?

So how would find say write a program to calculate Pi to N number of places?

View 3 Replies View Related

C :: Program To Calculate Loan Balance Table

Sep 22, 2013

so i am just hitting writers block on this one... its lengthy and i am very little into it...

The program takes 4 entered values (total loan, apr, monthly payment, and length of loan).

It is to put out a table that gives the new loan balance each month and the total interest payed at the bottom.

View 2 Replies View Related

C :: Program Which Calculate Time Difference Between Two Daytime

Jul 4, 2013

I'm challenged to write a program which calculates the time difference between two daytime.

compiler doesn't give an error, yet the warning: "format '%d' expects argument of type 'int *', but argument 3 has type 'int' [- Wformat]" for lines 24 and 26

However, by entering the first time the program crashes anyway. so I assume I do really need some pointer to make it read from the console can you see where my problem is?

Code:

#include <stdio.h>
#include <stdlib.h>
typedef struct {
int Second;
int Minute;
int Hour;
}Time;

[Code]...

View 4 Replies View Related

C :: Program To Calculate Business Days In A Year

Nov 11, 2014

I need to make a program to calculate the business days (Monday-Friday) in a year in C. As example:

Input
2026
Output
261

I need to consider that the year could be a leap year and that every year can start with a different day. My Problem is that i dont know how to implement the right number of business days in C. I wrote down the business days in Excel for 2010-2040. I cant see any system behind it, some years have 261 business days, some have 260 or 262 but in no order.

View 7 Replies View Related

C :: Create A Program That Will Calculate A Shipping Cost?

Feb 16, 2015

So im trying to create a program that will calculate a shipping cost. I'm stuck on trying to calculate the actual milage and cost. Example being 1400 miles for a 2lb package would be $2 for every 500miles. so it would cost $6. But Im having trouble getting the program to round up the 1400 to 1500 so it charges the correct amount.

I know there would have to be a way to do this without programming all the conditions.

Also the course has not reached loops yet.

Code:

// This program will calculate the shipping charges.// The shipping rates are based on per 500 miles shipped.
// They are not pro-rated, i.e., 600 miles is the same rate as 900 miles or 1000 miles.
#include <stdio.h>
#include <stdlib.h>

[Code]......

View 1 Replies View Related

C :: Program To Calculate Factorial Of Numbers - For Loop

Feb 5, 2013

I have been working on a program to calculate the factorial of numbers. Part of my code is copied and modified from the FAQ about validating numbers in user input.

I have encountered a problem with the for loop that I am using near the end of my code. No matter what I do, it seems that my loop only does the multiplication of b = a*(a-1) and then prints. For example, inputting 5 will result in a print of 20, but the factorial is 120.

Code:
int main(void) {
char buf[BUFSIZ];
char *p;
long int a;
long int b;
long int i;

printf ("Enter a number to be factorialized: ");

[Code] ....

View 5 Replies View Related

C++ :: Write A Program That Uses Arrays To Calculate Sum And Display It

Nov 4, 2013

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;

[Code] .....

View 1 Replies View Related

C++ :: Program To Calculate A Grade Letter Into Number?

Feb 7, 2013

So I have to write a program to calculate a grade letter into a number.

Letter grades are A, B, C, D, and F, possibly followed by + or –. Their numeric values are 4, 3, 2, 1, and 0. There is no F+ or F–. A + increases the numeric value by 0.3, a – decreases it by 0.3. If the letter grade is illegal (such as "Z"), then your output should be "INVALID LETTER GRADE"; If the combination is illegal (such as "A+" or "F-") then your output should be "INVALID GRADE COMBINATION"

Also the code should look like this
Enter your letter grade: C+
Grade value is [2.3]

// Input
cout << "Enter your letter grade: ";
string s;
cin >> s;

[Code].....

View 2 Replies View Related

C++ :: Program To Calculate Golfers Handicap For Each Score

Apr 28, 2014

I need starting a do-while loop in my program that runs up to 10 time that asks the user to enter up to 10 scores, which include the slope and rating for the course, and calculates the handicap for each score. Here's what I have so far:

//This program calculates a golfers handicap.
#include <iostream>
#include <string>
using namespace std;
int main() {
int score, slope;
double rating, handicap;

[Code] ....

View 1 Replies View Related

C/C++ :: Writing Program That Will Calculate Employee Salary?

Jan 31, 2014

I am having some trouble with my class assignment. We need to write a C program that will calculate the employee salary. There are 5 employees that will need to be calculated. We are required to use a loop also.

So far this is what I have but I am receiving errors when running the program.

#include <stdio.h>
int main() {
int clock_num; /* employee clock number */
float gross; /* gross pay for week (wage * hours) */
float hours; /* number of hours worked per week */
float wage; /* hourly wage */
/* Prompt for input values from the screen */
printf ("This is a program to calculate gross pay.

[code]....

View 3 Replies View Related

C/C++ :: Program Using Multiple Functions That Will Calculate Salary?

Feb 21, 2014

I already wrote a program that will calculate the gross pay for a set of employees.

I want modify the code by adding multiple functions.

I want to create a separate function whenever possible to break up the program.

For example, I would like have a function for obtaining the hours from the user, another function for calculating overtime hours, another for calculating gross pay and another function for producing the output.

#include <stdio.h>
#include <stdlib.h>
#define STD_HOURS 40.0
#define OT hour>STD_HOURS
#define SIZE 5
int main() {
int clockNumber[SIZE] = {98401, 526488, 765349, 34645, 127615}; /* employee ID */

[code]....

View 2 Replies View Related

C :: Calculate Product Of Two Matrices - Segmentation Fault In Program

Oct 29, 2014

New to C Programming, I have a problem with a little program I made that calculates the product of two matrices.

And here is the error I get:

View 4 Replies View Related

C++ :: Program To Calculate Average Of 3 Numbers - Undeclared Identifier

Sep 22, 2013

Write a program that will calculate average of 3 numbers

#include <iostream>
int
main(){
// prototypes:
float add_and_div(float, float,
float);

[Code] .....

i get the following errors:

error C2065: 'cout' : undeclared identifier
error C2065: 'cin' : undeclared identifier
error C2065: 'cout' : undeclared identifier
error C2065: 'endl' : undeclared identifier

View 2 Replies View Related

C++ :: Test Scores Program With Pointers - Calculate Average?

Apr 7, 2013

I have created a program that allows for a user-defined number of test scores as input. After the user enters these scores, the program calculates the average test score. Here is my code:

#include <iostream>
#include <iomanip>
using namespace std;
// Function prototypes
double getAverage(double*, int);

[Code] .....

I am having trouble with the final part of my program. How do I pass the array of test scores to a function that calculates how many people got an A (90+) on the test? The final output should look like this:

The average of those scores is:
The number of A grades is:

View 2 Replies View Related







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