Give the output on the screen of the following program (indicate a space using this symbol _):
#include<stdio.h>
double mystery(int T[], int i)
{
int k;
for(k=0 ; k<i ; k++)
T[k] -= T[i] - k;
return T[k] + 1;
}
int main()
{
int a = 7, b = 4, c, T[] = {4,-4,8,0};
double x = 0.02, y = -0.05, z = 0.1 ;
c = 1;
for (a = 0; a < 5; a++)
{
for (b = a; b < 5; b++)
switch (a-b) {
case 0:
case 2:
case 4: c++;
case 6: break;
case 8: c--;
case 12:
default: c++;
}
printf("#%d# %d ##\n", 12 + a , c);
}
printf("#17# %0.0lf ##\n", mystery(T, 2));
printf("#18# %d ##\n", T[0]);
printf("#19# %d ##\n", T[0%4]);
printf("#20# %d ##\n", -T[0]%3);
return 0;
}
Difficulty level
This exercise is mostly suitable for students
#12# 6 ##
#13# 10 ##
#14# 13 ##
#15# 15 ##
#16# 16 ##
#17# 9 ##
#18# -4 ##
#19# -4 ##
#20# 1 ##
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Implementation of a deque using a doubly-linked list