114k views
20 votes
What is the output of the following program fragment. Choose appropriate data-types of variables to match output.

i=7;j=8;k=9;
printf(“%d”,(i+10)%k/j);

User KevinTale
by
3.6k points

1 Answer

3 votes

Answer:

1

Step-by-step explanation:

Given :

i=7;j=8;k=9;

printf(“%d”,(i+10)%k/j);

The printf function only displays the result

%d - is used for the display format

However, the actual calculation is in the expression: (i+10)%k/j

Given the variables :

i = 7 ;

j = 8 ;

k = 9 ;

(i + 10) = (7 + 10) = 17

(i + 10) % k = 17 % 9

% = remainder value after division

17 % 9 = (17 / 9) = 1 remainder 8

17 % 9 = 8

Hence,

(i + 10) % k = 8

(i + 10) % k / j

j = 8

8 / 8

= 1

User GreenMatt
by
3.8k points