-7

Now I have this number 193456787 stored in an array in C with each digit in a cell, how do I construct a four digit number from the digits in even numbered positions for example like 9468 ?

Omar
  • 3
  • 1

1 Answers1

0

Well, quite obviously:

const int digits[] = { 1, 9, 3, 4, 5, 6, 7, 8, 7 };
const int num = 1000 * digits[1] + 100 * digits[3] + 10 * digits[5] + digits[7];

Just add the digits together, scaled by the appropriate weights of course.

unwind
  • 391,730
  • 64
  • 469
  • 606