C/C++ :: Fahrenheit To Celsius And Celsius To Fahrenheit Code?
Mar 16, 2015
Im trying to write a code that converts Fahrenheit to Celsius and Celsius to Fahrenheit. Im having trouble prompting the user to enter in "f" for Fahrenheit and "c" for Celsius. I am not getting any errors when running the program but the output includes all the cout statements even after I have used :
if (g=='f'|| g=='F') and if (g=='c'|| g=='C')
#include<iostream>
using namespace std;
int main() {
int f_temp;
int c_temp;
int f,c,g; {
cout << "Choose between Fahrenheit and Celsius: " << endl;
[code]....
View 6 Replies
ADVERTISEMENT
Feb 5, 2013
I know my current program will not compile. How can I store the the start temperature so it can be used again in the final printf statement "start degrees Fahrenheit is converted Celsius."?
Note - I want to use the float data type for precision.
Code:
//THIS PROGRAM WILL CONVERT TEMPERATURES BETWEEN DEGREES FAHRENHEIT AND DEGREES CELSIUS
#include <stdio.h>
int main(void)
[Code].....
View 4 Replies
View Related
May 28, 2014
One of the questions requires writing up a code, that converts Fahrenheit scale to Celsius scale.
The relation between temperature in ◦ C and ◦F is given by the formula:
◦C = 5/9 . ( ◦F - 32 )
Write a program that prints a table (just two columns without any borders) with temperature in ◦F and ◦C for temperatures between 0 and 300 ◦F in steps of 20◦. Compile and run your program. I wanted to approach this problem via arrays and for loops, and I wrote up this
Code:
#include<stdlib.h>
#include<stdio.h>
int main() {
// begin main()
// units
double[] celsius = new double[ 16 ];
double[] fahrenheit = new double[ 16 ];
[Code] ....
Now when I'm trying to compile that, the compailer throws an error which makes absolutely no sense to me.
Code:
fahrenheitCelsius.c: In function ‘main’:
fahrenheitCelsius.c:18:9: error: expected identifier or ‘(’ before ‘[’ token
double[] celsius = new double[ 16 ];
[Code] ....
View 7 Replies
View Related
Mar 8, 2013
The program should create two integer variables for the temperature in Celsius and Fahrenheit. Initialize the temperature to 100 degrees Celsius. In a loop, decrement the Celsius value and compute the corresponding temperature in Fahrenheit until the values are the same. But for some reason i either get no output or an out put of -43.
#include <iostream>
using namespace std;
int main() {
int celsius;
int fahrenheit;
fahrenheit = 0;
celsius = 100;
[Code] ....
View 1 Replies
View Related
Jan 6, 2013
So here is the program:
//Program to convert from Fahrenheit to Celcius
#include <iostream>
double fahrenToCelsius (double t);
//precondition:
//t is a valid tempreture in Fahrenheit
//postcondition:
//returns equivalent temp. in Celcius
[Code] .....
And here is the problem:
[Linker error] C:UsersOwnerAppDataLocalTempcckex8SZ.o:fahrenToCelsius.cpp: (.text+0x3d): undefined reference to `fahrenToCelsius(double)'
collect2: ld returned 1 exit status
I'm suspecting the program maybe that I saved it wrong? I saved it as fahrentoCelsius.cpp inside the folder "Work" ( I created this folder) which is inside the folder "Dev-cpp".
View 1 Replies
View Related
Oct 28, 2013
This C++ question is related to Temperatures and Our task is to : Write a well-documented C program that prints out a table of temperatures in Celsius, from 0 to 100, in steps of 5 degrees, with the equivalent Fahrenheit.
To convert temperatures from Celsius to Fahrenheit use the equation : Temp(F) = Temp(C)*9/5 + 32
Include headings on the columns of figures.
Use the following formatting in your printf to produce a tabulated output:
Printf(“%4.1f %4.1f
”, Cent, Fahr);
This format will print each variable in a fieldwidth of 4 digits, with one place of decimal. The ‘ ’ inserts a tab to space the columns. This is our code, but for some reason its not working.
#include<stdio.h>
void main() {
int Cent=1, Fahr=1;
int Temp;
int F;
int C;
[Code] ....
View 3 Replies
View Related
Feb 8, 2014
I am trying to write a unit convertor for converting temperatures Celsius, Kelvin and Fahrenheit.
Code:
if (select_one == 't' || select_one == 'T'){// this one works perfectly...
//This section does not tell you the use of variables.
//The use of variables can be seen as comments in the main program
[Code].....
This part of code will be part of a larger Unit Converter program. Do you think this method of conversion is wise? The error codes are for debugging use only.
I convert all temperatures of all units, whether Celsius, Kelvin or Farhenheit into Celsius and then convert it into the units the user wants.
For example:
Kelvin -----> Celsius ------------------> Farhenheit
(Input) (base of conversion) (desired output unit)
Do you think this type of conversion is okay?
View 1 Replies
View Related
Mar 9, 2015
I need to write a program to input 6 temperatures in degrees Fahrenheit and output it in degrees Celsius. I used a for loop but it keeps giving me 0 as the output whenever I enter a temperature...
Code:
#include <stdio.h>
#include <math.h>
int main() {
double farenheit,celsius;
for(int i=0; i<6; i++) {
printf("Enter temperature in degrees farenheit: ");
scanf("%lf",&farenheit);
celsius = (5/9)*(farenheit-32);
printf("Temperature in degrees celsius: %lf ",celsius);
} }
View 5 Replies
View Related
Dec 1, 2014
I am using Microsoft Visual C++ 2010 Express.
This is my Algorithm. [URL] ....
#include <iostream>
#include <iomanip>
using namespace std;
//function prototypes
int getFahrenheit();
double calcCelsius(int tempF)
[Code] ....
for some reason it keeps giving me a
Error C2144: syntax error: 'int' should be preceded by ';' on line 16 column 1
Error C2143: syntax error: missing ';' before 'return' on line 34 column 1
IntelliSence: expected a ';' on Line 34 Column 2
I have tried to fix both of these problems and no matter what I do I either get more errors or they wont go away...
View 5 Replies
View Related
Feb 10, 2015
I am trying to write a program where i take temperature in Fahrenheit and convert it into centigrade. I keep getting this error "The program '[5980] lab3.exe: Native' has exited with code 0 (0x0)."
My Code is :
#include <iostream>
using namespace std;
int main() {
double fahrenheit, centigrade;
cout << "Enter the temperature in Fahrenheit: ";
cin >> fahrenheit;
centigrade = (5/9)(fahrenheit-32);
cout << "The Temperature in Centigrade is " << centigrade << endl;
return 0;
}
View 4 Replies
View Related
Apr 15, 2013
I have assignment which requires me to print out and array code and a pseudo code. I dont no what a pseudo code is,.
View 2 Replies
View Related
Apr 13, 2014
I have a class 'A' which is almost perfect for my needs. Class 'B' uses class 'A' I've now designed Class 'C' and Class 'D' and noticed that there is a good chunk of code in class 'B', 'C' and 'D' for using Class 'A' is duplicated. I've separated out this code in specific, standalone functions in each of the classes. Now I'm wondering where this code should go. At the moment, the functions are duplicated in the three calling classes (B, C and D). Placing the functions into class 'A' would break the single responsibility principle. Inheritance to add functionality would likely break both SRP and LSP. The one that seems that it may work is composition.
However, Is designing a complete class just for a few functions over kill?
Would it be valid for classes 'B', 'C' and 'D' to access both the new class 'E' (which would depend on A) and the old class 'A' (which would have to be the same instance as the instance in the new class 'E'), or should the new class 'E' provide sufficient functionality so that Classes B, C and D don't need to access Class A directly? It would seem that its then an incomplete interface of the original object with additional functionality (ie, incompatible) Or should I do it a completely different way?
View 4 Replies
View Related
Sep 17, 2014
i wrote the following code :
Code:
#include<stdio.h>#include<conio.h>
#include<stdlib.h>
int a[][4] = {15,9,10,25,6,2,4,7,32,19,42,8,21,17,18,0};
void boxes();
void display();
void main()
{int ch,r=3,c=3,t;
[Code]...
not able to esc when i press esc key.how to get rid of this.
View 4 Replies
View Related
Apr 17, 2013
I wanna to know how can i get a string from the user and treat it as a c++ code ..is there any way to do that ??
View 7 Replies
View Related
Oct 13, 2013
I want to make a RTS game but how can I code an AI for RTS games. How to do that?
View 5 Replies
View Related
May 4, 2014
I am making a game and want to make an updater that grabs the source code from a page on the web. Can this use things that are available to all platforms? It could just be something that grabs the text from the page and executing it (maybe using something like Python's exec() command ?) BTW I'm using mac
View 1 Replies
View Related
Feb 25, 2014
this is my code i want to put the part where i have it do multiplication and addition into functions. and then call them so that it can run the addition and multiplication. Heres my code
# include <iostream>
using namespace std;
int main(){
[Code].....
View 2 Replies
View Related
Feb 24, 2015
I'm pretty new to C++ and I'm on Binary Trees in "Jumping into C++"! I've just created a DLL project on Code::Blocks, and I cannot get it to build and run: "You must select a host application to "run" a library..." is the message that I'm getting when I run the main code file. It's had no changes to it (except for a few extra, unnecessary line feeds), and it's the file which Code::Blocks generates on a DLL project.
View 13 Replies
View Related
Jan 16, 2014
whats wrong with this code, I'm trying to parse a .js file and replace all the ";" with "; " i.e add a new line after each ";". So I load the file into a char[] buffer then assign a string to this contents of this buffer. Then loop char by char through using an iterator and check for a ";", if found use replace. So int i gets to about 85898 then crashes with unknown error, 'i' should reach about 175653. It does work up till it crashes. And, is this not a simpler way to load a file into a buffer, there is in C.
Code:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <vector>
#include <stdlib.h>
int main()
[code]....
View 8 Replies
View Related
Sep 27, 2014
I have a function that needs to return a "uint8_t" value. However before doing the processing I need to perform a test on the argument to check if it's between expected boundaries. Although this function works it gives (a logical) warning that not always a value is returned although expected. What is the normal way for functions like these where I normally should return e.g. -1 in case the test doesn't succeed and otherwise the uint8_t (t) value?
Code:
uint8_t myFunc(int a) {
if (a >= 0 && a <= 100) {
// Perform actions
uint8_t = ...
return t;
}
}
View 9 Replies
View Related
Apr 11, 2013
I have a code that I'd like to debugg it.
Question
1 - What is the correct command line to use the debugger ?
2 - Do I need to install additional software for the debugger ?
if yes what it's name?
I use ububtu 12.4compiling command: gcc abc.c -lpthread -o abc
View 3 Replies
View Related
Aug 25, 2014
I am using windows 64 bit 2007 , codeblocks and ive tried googling on how to strip all symbols to binary so that the people i send it to cannot read the game files but ive not found anything much... How do i do it on codeblocks..? Code:
View 4 Replies
View Related
Mar 11, 2014
I've had with visual studio but nothing seems to be working. No matter what I do even with simple programs, like Hello World, I'm always getting an error about a .pch header file.fatal error C1083: Cannot open precompiled header file: 'DebugConsoleApplication1.pch': No such file or directory
This is only for one of the programs I've made but I'm pretty new to programming and I've not even used the header files for anything so I have no clue how to resolve this problem.
View 2 Replies
View Related
Mar 31, 2013
I want the 'counter' loop to go through twice, each time reading in 15 characters from the standard input, then going through the evalutor
Code:
#include <stdio.h>
#include <ctype.h>
int main (void)
{
char inputtedhand[64];
int NumC=0, NumD=0, NumS=0, NumH=0;
}
[code]...
View 9 Replies
View Related
Mar 8, 2013
I am in try to use PlPlot library (for plotting) in C with code::blocks IDE (ver 10.05) on windows-7 plateform. I downloaded "plplot-5.9.9.tar" and unzipped it. In documentation it is not very clear to me (I am not expert in using third party lib.), how this library can be used with code::blocks i.e. where I have to save the lib, what should be added in compiler and debugger settings etc. It also seems from document that "makefile" (linux type!!) is necessary for Windows also? I am also unaware of MSYS makefile generator (given on Wiki page) on windows?
View 2 Replies
View Related
Dec 12, 2014
i recently started programming. i mean I've been exposed to programming for the first time about a week ago. I've been following the tutorial here and playing around with my own code. For some reason, this code works while receiving decimals but not fractions.
Code:
#include <stdio.h>
int main()
{
float kd;
float kd_2;
printf("Please enter your k/d
");
scanf("%f", &kd );
}
[code]....
View 7 Replies
View Related