Why does this integer division yield 0?

Could someone tell me why the following code is outputting `0` at the marked line? It seems as if everything is correct but then when I try to get the result near the end it's giving me 0 each time. #include int main() { // Gather time-lapse variables int frameRate, totalLengthSecs; printf("How many frames per second: "); scanf("%i", &frameRate); printf("--> %i frames confirmed.", frameRate); printf("\nDesired length of time-lapse [secs]: "); scanf("%i", &totalLengthSecs); printf("--> %i seconds confirmed.", totalLengthSecs); int totalFrames = frameRate * totalLengthSecs; printf("\nYou need %i frames.", totalFrames); // Time-lapse interval calculation int timeLapseInterval = totalLengthSecs / totalFrames; printf("\n\n%i", timeLapseInterval); // <-- this prints 0 return 0; }
What are you typing into stdin for "Desired length of time-lapse"?

以上就是Why does this integer division yield 0?的详细内容,更多请关注web前端其它相关文章!

赞(0) 打赏
未经允许不得转载:web前端首页 » CSS3 答疑

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

前端开发相关广告投放 更专业 更精准