Hey guys, thank for the help before and maybe you can help me a little more :-).
Here is the question they are asking...
"Write a statement that reads a floating point (real) value from standard input into temperature. Assume that temperature. has already been declared as an double variable."
I been trying to figure out what it means. I tried scanf, but just get some error message. Any help would be great. Thanks.
Oh btw this isn't a homework question. I been using this site to help me learn C++ the site is turingscraft.
12 9809
Hey guys, thank for the help before and maybe you can help me a little more :-).
Here is the question they are asking...
"Write a statement that reads a floating point (real) value from standard input into temperature. Assume that temperature. has already been declared as an double variable."
I been trying to figure out what it means. I tried scanf, but just get some error message. Any help would be great. Thanks.
post your code an we can try to figure out what is wrong
post your code an we can try to figure out what is wrong
Well, I tried these.. -
-
printf("%f",temperature);
-
-
and I tried
-
-
scanf("%f",temperature);
-
-
and I even messed around and gave temperature a value of 10.
-
I just don't really understand what they are asking for exactly. I hope that helps...
Well, I tried these.. -
-
printf("%f",temperature);
-
-
and I tried
-
-
scanf("%f",temperature);
-
-
and I even messed around and gave temperature a value of 10.
-
I just don't really understand what they are asking for exactly. I hope that helps...
when scanf() converts characters into a numeric value it has to return that value into the variable. To do this it need the address in memory of the variable. To pass the address you use the & (address of operator), e.g. -
scanf("%f",&temperature); // ** & added
-
when scanf() converts characters into a numeric value it has to return that value into the variable. To do this it need the address in memory of the variable. To pass the address you use the & (address of operator), e.g. -
scanf("%f",&temperature); // ** & added
-
Hello, I also had tried the & and I believe I got the error "Suggestion: You changed temperature, but did not read a value into it."
So would I have to put something like temperature = 10 is that "reading a value into it."
Hello, I also had tried the & and I believe I got the error "Suggestion: You changed temperature, but did not read a value into it."
So would I have to put something like temperature = 10 is that "reading a value into it."
try this program which reads a value from the keyboard and returns it into the variable temperature -
#include <stdio.h>
-
-
int main()
-
{
-
float temperature;
-
scanf("%f",&temperature); // ** & added
-
printf("%f\n",temperature);
-
system("pause");
-
}
-
try this program which reads a value from the keyboard and returns it into the variable temperature -
#include <stdio.h>
-
-
int main()
-
{
-
float temperature;
-
scanf("%f",&temperature); // ** & added
-
printf("%f\n",temperature);
-
system("pause");
-
}
-
Hello, that works in my c++ program, but not for the website. I have to put
[code]
scanf("%f",&temperature);
printf("%f\n",temperature);
[code\]
You changed temperature, but did not read a value into it.
Unexpected identifiers: printf
Write a single statement, performing the input as directed.
The site asks
Write a statement that reads a floating point (real) value from standard input into temperature. Assume that temperature. has already been declared as an double variable.
I know scanf and printf does what the first line asks for, but could've the site have a grammar error or temperature. <<notice the period must be included in the code?
I'm sorry if this is confusing as I am confused as well.
what exactly are you trying do, i.e. what is the specification of the program? what website are you talking about?
what exactly are you trying do, i.e. what is the specification of the program? what website are you talking about?
Hello, the website I am using is www.turingscraft.com
You have some sort of instant message program I can send you my print screen of or I'll just find a website to host it.
Thanks again!
After a few hours of research, I figured out the correct code: - scanf("%lf",&temperature);
what compiler are you using??
Don't say you are compiling on that site. its not a very good answer.
follow the link
to get a detail of scanf string format.
%lf is used for double
%f is for float
@johny10151981
I'm using Pelles C.
You would use %lf, because it the prompt says "temperature" has been declared as a double...
scanf ("%lf", &temperature);
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Sven Kobow |
last post by:
Hello,
I'm not yet a python programmer but a python user. I faced a problem
with tiny fonts in a wxPython app on a GNU/Debian system. Under Gentoo
Linux the fonts are displayed in a normal...
|
by: Mel |
last post by:
i would like to place a tiny image on the top-left corner of all screens and
on clicking the image to to http://www.somewhere.com url
can you please help ?
|
by: drj0nson |
last post by:
Without getting too mathematical : how do you print/handle big numbers?
for ( int i = 1 ; i < 10 ; i ++)
cout << (123456789 << i) << endl;
246913578
493827156
987654312
1975308624...
|
by: Pieter Linden |
last post by:
The answer to this one is probably "test it yourself and find out!",
but I'll ask anyway. Pursuant to my previous question - sending
separate recordsets to Word using the CreateTableFromRecordset...
|
by: Werner Nussbaumer |
last post by:
Hello
I am searching for a version of the Tiny C compiler for Windows 32. I
downloaded a version from http://fabrice.bellard.free.fr/tcc/ but the
make command displayed error messages:
...
|
by: Justin Naidl |
last post by:
A group of friends and I are doing a RPG (role-playing game) maker for a
school project. It occured to us, however, that if you want the user to be
able to have almost complete control over the...
|
by: soeren |
last post by:
Hello,
two days ago I stumbled across a very strange problem that came up when
we were printing tiny double numbers as strings and trying to read them
on another place. This is part of an object...
|
by: Martijn Mulder |
last post by:
I want to implement a tiny window in my application, one that you typically
invoke via the menu-option Window -Toolbar. It must be floating, not
restricted to the client area of the controlling...
|
by: rtk |
last post by:
I'm looking for information on building a tiny/small/minimalist/
vanilla python interpreter. One that implements the core language and
a few of the key modules but isn't tied to any specific...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |