What is the solution of displayed error. Please reply | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

What is the solution of displayed error. Please reply

https://code.sololearn.com/cZagjdOwCPAY/?ref=app

2nd Jan 2020, 5:31 PM
Pranav Charate
Pranav Charate - avatar
10 Answers
+ 1
You have not even declared your variable "f" then how can you even use it. The integer variable "c" takes the user input but then you are trying to assign a float value to it. Do you understand? Atleast tell us what conversion do you want so that we can help you.
5th Jan 2020, 9:27 AM
Avinesh
Avinesh - avatar
+ 1
If you take int value from user and you convert it into float then you will just get the same number followed by 0's. Eg- int a = 10; float b = a; // output 10.000000
5th Jan 2020, 9:31 AM
Avinesh
Avinesh - avatar
+ 1
If that is what you want then do this int c; printf("enter no"); scanf("%d",&c); float f = c; printf("\nvalue is %f",f);
5th Jan 2020, 9:34 AM
Avinesh
Avinesh - avatar
0
What are you actually trying to do? I'm asking this because you are really confused and are not clear about the data types you are using and assigning.
2nd Jan 2020, 5:49 PM
Avinesh
Avinesh - avatar
0
What is meant by "Expected expression before'float' "??
5th Jan 2020, 9:23 AM
Pranav Charate
Pranav Charate - avatar
0
I want int value from user but want to display it in float value. Hence I was using data type conversion but it seems that syntax is somewhat wrong
5th Jan 2020, 9:29 AM
Pranav Charate
Pranav Charate - avatar
0
Thank you first for answering to my little question
5th Jan 2020, 9:31 AM
Pranav Charate
Pranav Charate - avatar
0
Yeah I know that
5th Jan 2020, 9:32 AM
Pranav Charate
Pranav Charate - avatar
0
Thanks
5th Jan 2020, 9:34 AM
Pranav Charate
Pranav Charate - avatar
0
Oh I got it. Doubt cleared
5th Jan 2020, 9:36 AM
Pranav Charate
Pranav Charate - avatar