Sunday, March 26, 2017

Array input and out and sum using function in c



///Array display using function

///write a program that will print their value and sum
#include<stdio.h>
int arrayDisplay(int b[],int i)
{
    int sum =0;
    for(i=0;i<5;i++)
    {
        printf("%d ",b[i]);
        sum =sum + b[i];

    }
   // printf("\nsum = %d\n",sum);
   return sum ;
}
void main()
{
    int a[]={3,4,5,6,7},i;
    printf("sum =%d",arrayDisplay(a,i));
}


No comments:

Post a Comment