Functions that return multiple values -C Example

Categories: C Programming language

#include <stdio.h>
#include <conio.h>

main()

{
int a[5]={2,4,,6,8,10};
int b[8]={1,3,5,7,9,11,13,15};
int c[10]={1,2,3,4,5,6,7,8,9,10};
clrscr();
printf (
"sum of the array a : %d \n",add(a,5));
printf ("sum of the array b : %d \n",add(b,8));
printf ("sum of the array c : %d \n",add(c,10));
}
add (int arr[], int n)
{
int i, sum=0;
for (i=0;i<n; i++)
sum+=arr [i];
getch();

return sum;
}

Output :

sum of array a : 30

sum of array b : 64

sum of array c : 55

Top Blogs
Introduction to Implementation of Queue using Linked List Published at:- Input and Output Functions in C Published at:- Importance of C Programming Language Published at:- How does C Programming Language Work Published at:- History of C Language : Introduction to C Programming Language Published at:- Benefits of C language over other programming languages Published at:- C Language Interview Question and Answers Published at:- Pointer declaration in C ,Address operator Published at:- C Program example: Input a number and print sum of its digits Published at:- What values are printed when we run following? Published at:- C Interview Questions And Answers Published at:- Learn C Programming language with example Published at:- C Memory Management ! Dynamic memory allocation Published at:- Structure in C: Introduction Published at:- Loops in C Published at:- Example of Function with no return type and no argument Published at:- Functions with arguments and no return values. Published at:- Functions with arguments and return values -C Examples Published at:- Functions that return multiple values -C Example Published at:- Types of Function in C ! Library Function in C ! User Defined Function In C ! Function Definition Published at:- C Functions ! What is a Function Published at:-
R4Rin Team
The content on R4Rin.com website is created by expert teams.