⚙️ C & C++ (SOLVED) Help float

Status
Not open for further replies.

missterry

Eternal Poster
Hi! Sa mga experts pwede po pa check anong mistake ko dito. Inches to feet conversion pala to. If I input 82 for my inches, if converted into feet which is by dividing it into 12, I should expect an output of 6.8. But in my case, 6.0 lang yung lumalabas. Pa help po. Here's my source code for your reference. Thank you so much!

C:
#include <stdio.h>

/*
User should input his/her height in inches
Output should be:
Height in inches:_
Your _ inches or _ feet tall
*/

int main(){
    int inches;
    float feet;
   
    printf("You height in inches: ");
    scanf("\n%d", &inches);
    printf("Height in Inches: %d", inches);
    feet=inches/12;
    printf("\nYou are %d inches or %.1f feet tall", inches,feet);
   
    return 0;
}[/ICODE]
 
You can make your inches data type to float or typecast it during computation.

Sa C kase pag nag divide kang int, int rin itatapon sayo.
 
Status
Not open for further replies.

Similar threads

About this Thread

  • 13
    Replies
  • 722
    Views
  • 2
    Participants
Last reply from:
mondiborak

Trending Topics

Online now

Members online
1,040
Guests online
2,551
Total visitors
3,591

Forum statistics

Threads
2,292,424
Posts
29,076,966
Members
1,209,347
Latest member
PHC-WhiteHalimaw
Back
Top