English, asked by pullemnarayana51, 6 months ago


The function printDigitSum(int *arr, int LENGTH) accepts an array arr and an integer LENGTH
as the size of arr. It is supposed to print the sum of digits of each integer in the array
separated by a comma.​

Answers

Answered by taraniamulu
1

Answer:

The function printDigitSum(int *arr, int LENGTH) accepts an array arr ... sum of digits of each integer in the array separated by a comma

Explanation:

follow me for more answers

Answered by mad210203
0

Program is given below.

Explanation:

#include <stdio.h>

int printDigitSum(int *arr, int LENGTH)

{

int n, sum, remainder,i;

printf("The sum of digits of each integer in the array is: \n");

for(i=0;i<LENGTH;i++)

{

sum = 0;

n = arr[i];

  while (n != 0)

  {

    remainder = n % 10;

     sum = sum + remainder;

     n = n / 10;

  }  

  if(i==LENGTH-1)

  printf("%d",sum);

  else

  printf("%d, ",sum);

}

}

int main() {

   int arr[10],length,i;

   printf("Enter the length or size of the array: ");

   scanf("%d",&length);

   printf("Enter the elements into the array:\n");

   for(i=0;i<length;i++)

   {

       scanf("%d",&arr[i]);

   }

   printDigitSum(&arr, length);

   return 0;

}

Refer the attached image for the output.

Attachments:
Similar questions