#include<stdio.h>
#include<conio.h>
void main()
{
void read(int *,int);
void dis(int *,int);
void add(int *,int *,int * ,int);
int a[5],b[5],c[5],i;
clrscr();
printf("Enter the elements of first list \n");
read(a,5); /*read the first list*/
printf("The elements of first list are \n");
dis(a,5); /*Display the first list*/
printf("Enter the elements of second list \n");
read(b,5); /*read the second list*/
printf("The elements of second list are \n");
dis(b,5); /*Display the second list*/
add(a,b,c,i);
printf("The resultant list is \n");
dis(c,5);
getch();
}
void add(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]);
fflush(stdin);
}
void dis(int d[],int i)
{
int j;
for(j=0;j<i;j++)
printf("%d ",d[j]);
printf("\n");
}
No comments:
Post a Comment