Addition of two arrays element in C - DS TUTORIAL - onwnxcvnne
Headlines News :
Home » , , » Addition of two arrays element in C - DS TUTORIAL

Addition of two arrays element in C - DS TUTORIAL

Written By jomon on Monday 16 April 2012 | 08:38

how to get the sum of each element of an array. There are three function in this given example one for reading the array element, second for writing on console and last for addition of both array's element.

Code:

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

void
main()
{

void
read(int *,int);
void
display(int *,int);
void
addarray(int * ,int *,int * ,int);
int
a[5],b[5],c[5],i;
clrscr();
printf("Enter the elements for first array \n");
read(a,5);
printf("Enter the elements for second array \n");
read(b,5);
addarray(a,b,c,i);
printf("The sum corresponding element of both array is : \n");
display(c,5);
getch();
}



void
addarray(int a[],int b[],int c[],int i)
{

for
(i=0;i<5;i++)
{

c[i]=a[i]+b[i];
}
}

void
read(int c[],int i)
{

int
j;
for
(j=0;j<i;j++)
scanf(" %d",&c[j]);
}


void
display(int d[],int i)
{

int
j;
for
(j=0;j<i;j++)
printf(" %d\n",d[j]);
}

Output:





Previous - Sum of array element in C

     Next - Inverse of an array in C

 Data Structure Tutorial 

1.  Introduction to Data Structures
2.  Pointer in C 
3.  Pointer and Structure in C
4.  Linear and Non-Linear Data Structure in C
5.  Array Implementation in C
6.  Sum of array element in C
7.  Addition of two arrays element in C
8.  Inverse of an array in C
9.  Merge of two arrays in C 
10.Overview of Linked List
11.Singly Linked List
12.Doubly Linked List
13.Circular Linked List
14.Count number of nodes
15.Split a list into two equal size list
16.Merge two list into a single list
17.Stack
18.Push and Pop operation of stack.
19.Push and Pop operation of stack using linked list.
20.Queue implementation using array.
21.Queue implementation using linked list.
22.Circular queue implementation using array.
23.Tree data structure
24.Representing Graph using adjacency list & perform DFS & BFS
Share this article :

0 comments:

Speak up your mind

Tell us what you're thinking... !

 
Support : Creating Website | Johny Template | Mas Template
Copyright © 2011. onwnxcvnne - All Rights Reserved
Template Created by Creating Website Published by Mas Template
Proudly powered by Blogger