#include <stdio.h>
#include <alloc.h>
#include <stdlib.h>
void main()
{
int i,n;
int *a,*b,*c;
printf(“How many Elements in each array…\n”);
scanf(“%d”, &n);
a = (int *) malloc(n*sizeof(int));
b = (int *) malloc(n*sizeof(int));
c =( int *) malloc(n*sizeof(int));
printf(“Enter Elements of First List\n”);
for(i=0;i<n;i++)
{
scanf(“%d”,a+i);
}
printf(“Enter Elements of Second List\n”);
for(i=0;i<n;i++)
{
scanf(“%d”,b+i);
}
for(i=0;i<n;i++)
{
*(c+i) = *(a+i) + *(b+i);
}
printf(“Resultant List is\n”);
for(i=0;i<n;i++)
{
printf(“%d\n”,*(c+i));
}
} /* End of main() */
/*—————————————
Output
How many Elements in each array…
4
Enter Elements of First List
1
2
3
4
Enter Elements of Second List
6
7
8
9
Resultant List is
7
9
11
13
—————————————-*/
Not Satisfied ? Just search & get the result
Related posts:
- C program to read N integers and store them in an array A, and so find the sum of all these elements using pointer. Output the given array and and the computed sum with suitable heading
- C program to read N integers (zero, +ve and -ve) into an array A and to a) Find the sum of negative numbers b) Find the sum of positive numbers and c) Find the average of all input numbers Output the various results computed with proper headings
- C program to read two matrices A (MxN) and B(MxN) and perform addition OR subtraction of A and B. Find the trace of the resultant matrix. Output the given matrix, their sum or Differences and the trace.
- C program to read a matrix A (MxN) and to find the following using functions a) Sum of the elements of each row b) Sum of the elements of each column c) Find the sum of all the elements of the matrix Output the computed results with suitable headings
- C program to accept an array of integers and delete the specified integer from the list
