-->

program to get difference of all elements of two one dimensional arrays.

using turbo c++
----------------------------------------------------------------------------------------------------------
//program to get difference of all elements of two one dimensional arrays.
#include<stdio.h>
#include<conio.h>
void main()
{
int array_1[100],array_2[100];
int i;
int total_element;
printf("enter size of array\n");
scanf("'%d",&total_element);
printf("enter elements of first array\n");
for(i=0;i<total_element;i++)
{

           scanf("%d",&array_1[i]);
  }

printf("now enter for second array\n");
for(i=0;i<total_element;i++)
{
 
           scanf("%d",&array_2[i]);
}
 printf("the summed array is\n");
for(i=0;i<total_element;i++)
{
           printf("%d\n",array_1[i]-array_2[i]);
}
getch();
}

--------------------------------------------------------------------------------------------------------
using codeblocks or dev c++/online compiler
-------------------------------------------------------------------------------------------------
//program to get difference of all elements of two one dimensional arrays.
#include<stdio.h>
int main()
{
int array_1[100],array_2[100];
int i;
int total_element;
printf("enter size of array\n");
scanf("'%d",&total_element);
printf("enter elements of first array\n");
for(i=0;i<total_element;i++)
{

           scanf("%d",&array_1[i]);
  }

printf("now enter for second array\n");
for(i=0;i<total_element;i++)
{
 
           scanf("%d",&array_2[i]);
}
 printf("the summed array is\n");
for(i=0;i<total_element;i++)
{
           printf("%d\n",array_1[i]-array_2[i]);
}
return 0;
}




No comments:

Post a Comment