0
How do i print values of an array using macros in C
I've an array arr[] ={1,2,3,4,5,6,7,8,9} And I've to display arr[5],arr[2],arr[1],arr[3] Using just single printf statement and single format specifier %d so how do i do so There's no limitation for loops and using other format specifiers Here's the code I'm trying to do https://code.sololearn.com/cBA8W8IN75DN/?ref=app
3 Answers
+ 3
I'd use this for my printing:
printf("arr[%i] = %d\n",k,arr[k]);
If %i shouldn't be used, change to %c and change first k to k+48 (only works for k <= 9).
+ 3
He was restricted to one %d in original question, Baptiste E. Prunier.
0
John Wells why using %i or %c ? Why not %d or %1d ?