# Formula Error

Page 1 of 1

## 2 Replies - 559 Views - Last Post: 10 February 2013 - 10:15 PMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=311645&amp;s=4d76c65444086a2b7c053d131f3eb988&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 hungrymouth

• New D.I.C Head

Reputation: 0
• Posts: 38
• Joined: 18-November 12

# Formula Error

Posted 08 February 2013 - 05:15 PM

=I'm not sure why my celsius,temperature and n= pv\rt arent showing up when I compile it. Instead I get this error that the variable f is being used without initial I'm not sure what to do.
```
#include "stdafx.h"
#include <iostream>
#include <iomanip>

#define PI 3.14159
#define g  9.81
using namespace std;

int main()
{

double Volume,SurfaceArea,Circumference,Area,Sum, Base;
int F,K,C; // temperatures
double Number, a, l;
double P,V,R,T

Base = 10; // This is the base of the triangle
Height = 3;
Area = 1 * Base * Height / 2;
cout << "\n\t\tThe Area of this beautiful triangle = "
<< Area;

//Volume of Sphere
Height =  3;
Volume = 4/3 * PI * Radius * Radius;
cout << "\n\t\t The volume of this cone = " << Volume;

//The Sum
Number = 4;
a = 1;
l = 7;

Sum = Number/2 * (a+l);
cout<<"\n\n\n The Sum of this sum = " << Sum;

// Lateral Area of  Cone
SlantHeight = 4;

Area = PI * Radius * SlantHeight * 1/2;
cout<<"\n\n\n The Area of this = " << Area;

//Celcius
C = 100;
cout << "\n\t\tThe value of 5 / 9 * (F - 32) = "
<< 5/9* (F - 32) << " Farenheit";

//Farenheit
F = 150;
cout <<"\n\t\tThe value of 9 / 5 * C + 32 = "
<< 9/5 * C + 32 <<" Celcius ";

// I don't know
P = 3;
V = 6;
R = 2;
T = 7;

Number = P*V/T*R;

cout<<"\n\n\t The value of P * V/ T* R = " << Value;

cout << "\n\n\n";
return 0;
}

```

Is This A Good Question/Topic? 0

## Replies To: Formula Error

### #2 jimblumberg

Reputation: 4887
• Posts: 15,265
• Joined: 25-December 09

## Re: Formula Error

Posted 08 February 2013 - 05:22 PM

Look closely at the following snippet:
```//Celcius
C = 100;
cout << "\n\t\tThe value of 5 / 9 * (F - 32) = "
<< 5/9* (F - 32) << " Farenheit";

//Farenheit
F = 150;
cout <<"\n\t\tThe value of 9 / 5 * C + 32 = "
<< 9/5 * C + 32 <<" Celcius ";
```

Where do you assign a Value to F? Before or after you try to use it?

Also note that the following calculation is probably not producing the results you think it is:
```9/5
```

This calculation will produce a value of 1, is that really what you want? Remember integers have no fractional parts.

Jim

### #3 raghav.naganathan

• Perfectly Squared ;)

Reputation: 410
• Posts: 1,449
• Joined: 14-September 12

## Re: Formula Error

Posted 10 February 2013 - 10:15 PM

Well, about your Pv/RT not giving the right value, it has to do with this line.

```cout<<"\n\n\t The value of P * V/ T* R = " << Value;
```

You seem to have given the variable as Value and in the previous line,
```Number = P*V/T*R;
```

You need to change the 'Number' variable to 'Value' for the code to work.

And as for the F and C values, you need to interchange lines 53 and 48.

Also, as Jim said, 9/5 is 1 whereas you want 1.something...you need to think as to what to add to the numbers to make it return a decimal value.

regards,
Raghav

This post has been edited by raghav.naganathan: 10 February 2013 - 10:19 PM

Page 1 of 1

 .related ul{list-style-type:circle;font-size:12px;font-weight:bold;}.related li{margin-bottom:5px;background-position:left 7px!important;margin-left:-35px;}.related h2{font-size:18px;font-weight:bold;}.related a{color:blue;}