C/C++ C++, question on double variable

  • Thread starter Thread starter loli12
  • Start date Start date
  • Tags Tags
    Variable
AI Thread Summary
In C++, the type of a variable determines how values are stored. When a double variable is assigned an integer value, such as 3, it will be stored as 3.0, reflecting its decimal nature. Conversely, if an integer is assigned to an int variable, it will simply hold the integer value without any decimal. For float variables, they will store values as floating-point numbers, preserving the decimal aspect. Thus, the variable type directly influences the representation of the assigned value.
loli12
I want to know if i use double variable and the input value is an integer, will that variable be stored as a decimal? How about for float variable?

ex. double x, and cin 3 for x, will x be stored as 3 or 3.0?

Thanks
 
Technology news on Phys.org
C++ will used the declared variable type when assigning values to said variable. So, if you had int x and you tried to store 3.14159 x would end up holding 3; likewise, float x would store all values as floats.
 
thanks a lot!
 
Thread 'Is this public key encryption?'
I've tried to intuit public key encryption but never quite managed. But this seems to wrap it up in a bow. This seems to be a very elegant way of transmitting a message publicly that only the sender and receiver can decipher. Is this how PKE works? No, it cant be. In the above case, the requester knows the target's "secret" key - because they have his ID, and therefore knows his birthdate.
I tried a web search "the loss of programming ", and found an article saying that all aspects of writing, developing, and testing software programs will one day all be handled through artificial intelligence. One must wonder then, who is responsible. WHO is responsible for any problems, bugs, deficiencies, or whatever malfunctions which the programs make their users endure? Things may work wrong however the "wrong" happens. AI needs to fix the problems for the users. Any way to...

Similar threads

Replies
5
Views
3K
Replies
10
Views
2K
Replies
8
Views
4K
Replies
25
Views
3K
Replies
17
Views
2K
Back
Top