-->

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;
}




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

using turbo c++
----------------------------------------------------------------------------------------------------------
//program to get sum 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 sum 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;
}




program to store any 'n' elements and display those which are >15.

using turbo C++
-----------------------------------------------------------------------
// program to store any 'n' elements and display those which are >15.
#include <stdio.h>
#include<conio.h>
void main()
{
    int a[100],n,i;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
        if(a[i]>15)
                {
                   printf("%d\n",a[i]);
                 }
    }
    getch();
}
-------------------------------------------------------------------------------------------------------------------
using online compiler/devC++/codeblocks with return concept
---------------------------------------------------------------------------------------------------------------------
// program to store any 'n' elements and display those which are >15.
#include <stdio.h>

int main()
{
    int a[100],n,i;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    for(i=0;i<n;i++)
    {
          if(a[i]>15)
                {
                   printf("%d\n",a[i]);
                 }
    }
    return 0;
}

program to swap any two values stored in array.Let there are 'n' numbers.


using turbo c++
-----------------------------------------------------------------------------------------------------------------------

//program to swap any two values stored in array.Let there are 'n' numbers.

#include <stdio.h>
#include<conio.h>
void main()
{
    int a[100],n,i,location,location1,j;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers before swapping, are:\n");
    for(i=0;i<n;i++)
    {

        printf("%d\n",a[i]);
                 
    }
    printf("enter number's first location to be swapped\n");
    scanf("%d",&location);
    printf("enter number's second location to be swapped\n");               
    scanf("%d",&location1);                                                 
    j=a[location-1];
    a[location-1]=a[location1-1];
    a[location1-1]=j;
    printf("numbers after swapping, are:\n");
    for(i=0;i<n;i++)
    {

        printf("%d\n",a[i]);
                 
    }
    
    getch();


}

-----------------------------------------------------------------------------------------------------------------------
using codeblocks/dev c++/online compiler with return concept
---------------------------------------------------------------------------------------------------------
//program to swap any two values stored in array.Let there are 'n' numbers.

#include <stdio.h>

int main()
{
    int a[100],n,i,location,location1,j;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers before swapping, are:\n");
    for(i=0;i<n;i++)
    {

        printf("%d\n",a[i]);
                 
    }
    printf("enter number's first location to be swapped\n");
    scanf("%d",&location);
    printf("enter number's second location to be swapped\n");               
    scanf("%d",&location1);                                                 
    j=a[location-1];
    a[location-1]=a[location1-1];
    a[location1-1]=j;
    printf("numbers after swapping, are:\n");
    for(i=0;i<n;i++)
    {

        printf("%d\n",a[i]);
                 
    }
    
    return 0;

}

program to delete an element stored in an array

using turbo c++ compiler
--------------------------------------------------------------------------------------------------------------
// program to delete an element stored in an array

#include <stdio.h>
#include<conio.h>
void main()
{
    int a[100],n,i,location,j;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers are:\n");
    for(i=0;i<n;i++)
    {

        printf("%d\n",a[i]);
               
    }
    printf("enter number's location to be deleted\n");
    scanf("%d",&location);
    for(i=0;i<n;i++)
    {
        if(i==location-1)
        {
            for(j=i;j<=n-1;j++)
            a[j]=a[j+1];                                         
        }                                                         
         
       
    }
    printf("number after deleting particular, are:\n");
    for(i=0;i<=n-2;i++)
    {

        printf("%d\n",a[i]);
               
    }
    getch();
}

---------------------------------------------------------------------------------
using devc++/codeblocks/online compiler with return concept.
----------------------------------------------------------------------------------
// program to delete an element stored in an array

#include <stdio.h>

int main()
{
    int a[100],n,i,location,j;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers are:\n");
    for(i=0;i<n;i++)
    {

        printf("%d\n",a[i]);
               
    }
    printf("enter number's location to be deleted\n");
    scanf("%d",&location);
    for(i=0;i<n;i++)
    {
        if(i==location-1)
        {
            for(j=i;j<=n-1;j++)
            a[j]=a[j+1];                                         
        }                                                         
           
    }
    printf("number after deleting particular, are:\n");
    for(i=0;i<=n-2;i++)
    {

        printf("%d\n",a[i]);
               
    }
    return 0;
}

program to display all numbers which are stored in odd positioned cell of array


using turbo C++
-----------------------------------------------------------------------
// program to display all numbers which are stored in odd positioned cell of array
#include <stdio.h>
#include<conio.h>
void main()
{
    int a[100],n,i;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers are:\n");
    for(i=0;i<n;i++)
    {
        if(i%2!=0)
                {
                   printf("%d\n",a[i]);
                 }
    }
    getch();
}


-------------------------------------------------------------------------------------------------------------------
using online compiler/devC++/codeblocks with return concept
---------------------------------------------------------------------------------------------------------------------
// program to display all numbers which are stored in odd positioned cell of array

#include <stdio.h>

int main()
{
    int a[100],n,i;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers are:\n");
    for(i=0;i<n;i++)
    {
        if(i%2!=0)
                {
                   printf("%d\n",a[i]);
                 }
    }
    return 0;
}

program to display all numbers which are stored in even positioned cell of array


using turbo C++
-----------------------------------------------------------------------
// program to display all numbers which are stored in even positioned cell of array
#include <stdio.h>
#include<conio.h>
void main()
{
    int a[100],n,i;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers are:\n");
    for(i=0;i<n;i++)
    {
        if(i%2==0)
                {
                   printf("%d\n",a[i]);
                 }
    }
    getch();
}


-------------------------------------------------------------------------------------------------------------------
using online compiler/devC++/codeblocks with return concept
---------------------------------------------------------------------------------------------------------------------
// program to display all numbers which are stored in even positioned cell of array

#include <stdio.h>

int main()
{
    int a[100],n,i;
    printf("enter total number\n");
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        printf("enter number for location=%d\n",i);
        scanf("%d",&a[i]);
    }
    printf("numbers are:\n");
    for(i=0;i<n;i++)
    {
        if(i%2==0)
                {
                   printf("%d\n",a[i]);
                 }
    }
    return 0;
}