473,407 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Just a tiny question.

64
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.
Jan 23 '07 #1
12 9809
horace1
1,510 Expert 1GB
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
Jan 23 '07 #2
td0g03
64
post your code an we can try to figure out what is wrong
Well, I tried these..

Expand|Select|Wrap|Line Numbers
  1.  
  2. printf("%f",temperature);
  3.  
  4. and I tried
  5.  
  6. scanf("%f",temperature);
  7.  
  8. and I even messed around and gave temperature a value of 10.
  9.  
I just don't really understand what they are asking for exactly. I hope that helps...
Jan 23 '07 #3
horace1
1,510 Expert 1GB
Well, I tried these..

Expand|Select|Wrap|Line Numbers
  1.  
  2. printf("%f",temperature);
  3.  
  4. and I tried
  5.  
  6. scanf("%f",temperature);
  7.  
  8. and I even messed around and gave temperature a value of 10.
  9.  
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.
Expand|Select|Wrap|Line Numbers
  1.   scanf("%f",&temperature);   // ** & added
  2.  
Jan 23 '07 #4
td0g03
64
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.
Expand|Select|Wrap|Line Numbers
  1.   scanf("%f",&temperature);   // ** & added
  2.  
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."
Jan 23 '07 #5
horace1
1,510 Expert 1GB
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
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.   float temperature; 
  6.   scanf("%f",&temperature);   // ** & added
  7.   printf("%f\n",temperature);
  8.   system("pause");
  9. }
  10.  
Jan 23 '07 #6
td0g03
64
try this program which reads a value from the keyboard and returns it into the variable temperature
Expand|Select|Wrap|Line Numbers
  1. #include <stdio.h>
  2.  
  3. int main()
  4. {
  5.   float temperature; 
  6.   scanf("%f",&temperature);   // ** & added
  7.   printf("%f\n",temperature);
  8.   system("pause");
  9. }
  10.  

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.
Jan 23 '07 #7
horace1
1,510 Expert 1GB
what exactly are you trying do, i.e. what is the specification of the program? what website are you talking about?
Jan 23 '07 #8
td0g03
64
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!
Jan 23 '07 #9
After a few hours of research, I figured out the correct code:

Expand|Select|Wrap|Line Numbers
  1. scanf("%lf",&temperature);
Dec 27 '11 #10
johny10151981
1,059 1GB
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
Dec 28 '11 #11
@johny10151981
I'm using Pelles C.

You would use %lf, because it the prompt says "temperature" has been declared as a double...
Dec 28 '11 #12
scanf ("%lf", &temperature);
Sep 14 '16 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
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...
5
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 ?
5
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...
2
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...
7
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: ...
2
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...
5
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...
2
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...
14
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
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...
0
Oralloy
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,...
0
jinu1996
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...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.