Q:

C Program to calculate sum, product of all One Dimensional Array Elements

0

C Program to calculate sum, product of all One Dimensional Array Elements

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

#include <stdio.h>
  
int main() 
{ 
    int arr[10]; 
    int sum,product,i;
  
   
    printf("\nEnter elements : \n"); 
    for(i=0; i<10; i++) 
    { 
        printf("Enter arr[%d] : ",i); 
        scanf("%d",&arr[i]); 
    } 
     
   
    sum=0;
    product=1;
    for(i=0; i<10; i++)
    {
        sum=sum+arr[i];
        product=product*arr[i];
    }
       
    printf("\nSum of array is     : %d"  ,sum); 
    printf("\nProduct of array is : %d\n",product); 
  
    return 0; 
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now