Give the output on the screen of the following program (indicate a space using this symbol _):
#include<stdio.h>double mystery(int A[], int i){ i = A[i] * 2; A[0] = 0; return i+1;}
int main(){ int i = 8, j = 5, k, A[] = {7,-2,0,1}; double x = 0.005, y = -0.01; char c = 'c', d = 'd'; //ASCII value of 'd' is 100
printf("#1# %d ##\n", (3*i-2*j) % (2*d-c)); printf("#2# %d ##\n", 2*((i/5)+(4*(j-3))%(i+j-2))); k = 8; printf("#3# %d ##\n", ++k); k = 8; printf("#4# %d ##\n", k++); printf("#5# %9.4lf ##\n", ++x); printf("#6# %d ##\n", c>d); x = 0.005; printf("#7# %+9.2lf ##\n", 2*x+(y==0)); printf("#8# %-9.2lf ##\n", 2 * x + y == 0); printf("#9# %d ##\n", (x>y) && (i>0) || (j<5)); printf("#10# %d ##\n", i%=j);
k = 1; for (i = 0; i < 5; i++) { for (j = 0; j < i; j++) { if (i*j % 2) continue; switch (i*j) { case 0: case 2: case 4: k++; case 6: break; case 8: k--; case 12: default: k++; } } printf("#%d# %d ##\n", 11 + i , k); } printf("#16# %0.0lf ##\n", mystery(A, 0)); printf("#17# %d ##\n", A[0]); printf("#18# %d ##\n", A[2%4]); printf("#19# %d ##\n", A[1]%3); printf("#20# %d ##\n", -A[1]%3); return 0;}
Difficulty level
This exercise is mostly suitable for students
#1# 14 ##
#2# 18 ##
#3# 9 ##
#4# 8 ##
#5# _ _ _1.0050 ##
#6# 0 ##
#7# _ _ _ _ +0.01 ##
#8# 0.01_ _ _ _ _ ##
#9# 1 ##
#10# 3 ##
#11# 1 ##
#12# 2 ##
#13# 4 ##
#14# 5 ##
#15# 8 ##
#16# 15 ##
#17# 0 ##
#18# 0 ##
#19# -2 ##
#20# 2 ##
Back to the list of exercises
Looking for a more challenging exercise, try this one !!
Lucky numbers