Search⌘ K
AI Features

A Fraction of an Int

Explore how integer fractions behave in C programming through puzzles that challenge your understanding of code output. This lesson helps you develop skills in analyzing and predicting program behavior involving integer operations.

We'll cover the following...

Puzzle code

Read carefully the code given below:

C
#include <stdio.h>
int main()
{
int a, b;
a = 5; b = 4;
printf("%d/%d = %f\n", a, b, a/b);
return(0);
}

Your task: Guess the output

Attempt the following test to assess your understanding.

1.

What is the expected output of the above code?

A.

5/4 = 0.00

B.

5/4 = 1.25

C.

5/4 = 0.125

D.

5/4 = 0.000000


1 / 1

Let's discuss the code and output together in the next lesson.