Question: Why is my upper digit 3.6? I wanted the Upper Digit value to be casted to an int, in this case, the Upper digit value

 Why is my upper digit 3.6? I wanted the Upper Digit

Why is my upper digit 3.6? I wanted the Upper Digit value to be casted to an int, in this case, the Upper digit value should be 3. For example, if float voltage is 4.5 => upper digit value is 4 and lower digit value is 5. How do I do this? The end result should show Upper digit = 4 and lower digit = 5 , not 0.5

TEST CASE:

4.5 = > Upper digit = 4 , Lower digit =5

3.6 => Upper digit = 3 , Lower digit = 6

1' /**** 2 3 Welcome to GDB Online. 4 GDB online is an online compiler and debugger tool for C, C++, Python, PHP, Ruby, 5 C#, VB, Perl, Swift, Prolog, Javascript, Pascal, HTML, CSS, JS 6 Code, compile, Run and Debug online from anywhere in world. 7 8 ********* 9 #include 10 11 int main() 12 { 13 14 float voltage = 3.6; 15 int VFU = (int)voltage; 16 17 float VFL = voltage VFU; 18 19 20 printf ("Voltage = %f v ", voltage); // print out the light voltage ADC value on Teraterm 21 printf ("Upper digit value = xf v ", VFU); // print out the Light voltage ADC value on ter 22 printf ("Lower digit value = %f V ", VFL); // print out the Light voltage ADC value on ter 23 24 return ; 25} 26 input main.c:24:33: warning: format **' expects argument of type double' but argument 2 has type 'int' [-Wformata] Voltage = 3.600000 V Upper digit value = 3.600000 V Lower digit value = 0.600000 V - - Program finished with exit code 0 Press ENTER to exit console

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!