0

any one out there help me to do this question

Write a program in C which must calculate how many tiles are needed to tile a floor. The tiles are 8 inches by 8 inches. Tiles can be used as a whole or a part of the tile can be used. Only one usable piece can be cut from a tile. That is, if a piece is cut from a tile, the rest of the tile must be thrown away. The program accepts the length and width of the room and returns how many whole tiles are used and how many part tiles are used. The length is given in inches. Input Format: Input consists of 2 integers. The first integer corresponds to the width of the room and the second integer corresponds to the length of the room. Output Format: Output consists of 2 integers. The first integer corresponds to the number of whole tiles used and the second integer corresponds to the number of part tiles used.

31st Dec 2017, 7:34 AM
Basharath Ahmed Chowdary
Basharath Ahmed Chowdary - avatar
4 Answers
+ 5
Why not you try it yourself and then post your code if you get stuck? 😉
31st Dec 2017, 7:43 AM
blackcat1111
blackcat1111 - avatar
+ 2
Following up to @Kurwius answer, I tried to rewrite line 15 by deleting the entire line and manually typing the code again (no copy-paste), it runs afterwards, in Code Playground, maybe you can try it, it was this line: printf("%d\n",count);
31st Dec 2017, 8:55 AM
Ipang
0
#include<stdio.h> int main() { int l,b; int i,j,extra; scanf("%d%d",&l,&b); int count=0; for(i=8;i<=l;i=i+8) for(j=8;j<=b;j=j+8) { count++; //printf("%d- %d\n",i,j); } i=i-8;j=j-8; printf("%d\n",count)­; if(i==l&&j!=b) { j=b-j; extra=i*j; extra=extra/(j*8); printf("%d",extra); } else if(i!=l&&j==b) { i=l-i; extra=i*j; extra=extra/(i*8); printf("%d",extra); } else if(i!=l&&j!=b) { j=b-j; i=l-i; extra=i*j; extra=extra/(i*j); printf("%d",extra); } else printf("0"); return 0; } it's showing error I can't figure out what's the error
31st Dec 2017, 8:08 AM
Basharath Ahmed Chowdary
Basharath Ahmed Chowdary - avatar
0
width = int(input()) length = int(input()) full_tile_length=length//8 full_tile_width =width//8 frac_length = (length/8)%1 frac_width =(width/8)%1 cl=0 cw=0 if(frac_width!=0 ): cw =full_tile_length if(frac_length!=0): cl =full_tile_width print(full_tile_length*full_tile_width) if(cl!=0 and cw!=0): print(cl+cw+1) else: print(cl+cw)
22nd Mar 2023, 2:19 PM
Varshith Kalwa
Varshith Kalwa - avatar