-->

program to know repetition of elements stored in array.

using turbo C++
-----------------------------------------------------------------------
//program to know repetition of elements stored in array.
#include<stdio.h>
#include<conio.h>
  void main()
  {
  clrscr();
  int arr[200],arr1[200],arra2_rep;    
  int size;     
  int i,j,k;      
 printf("enter size of elements \n");
  scanf("%d",&size); 
printf("enter array's elements\n");                 
  for(i=0;i<size;i++)
   {                            
     printf("enter elements for location=%d\n",i);
     scanf("%d",&arr[i]);      
   }
   printf("elements' sorting process started\n");
   for(i=0;i<size;i++)
   {
        arra2_rep=0;       for(j=i+1;j<size;j++)
        {
           if(arr[i]==arr[j])
             {
                 arr1[i]=ara2_rep++;
             }
       }
}
printf("repeated numbers are\n");
for(i=0;i<size;i++)
   {                            
     printf("number=%d and repeated times=%d\n",arr[i],arra1_rep[i]);      
   }
getch();
}

-------------------------------------------------------------------------------------------
in codeblocks
----------------------

//program to know repetition of elements stored in array.
#include<stdio.h>
  int main()
  {
  int arr[200],arr1[200],arra2_rep;    
  int size;     
  int i,j,k;      
 printf("enter size of elements \n");
  scanf("%d",&size); 
printf("enter array's elements\n");                 
  for(i=0;i<size;i++)
   {                            
     printf("enter elements for location=%d\n",i);
     scanf("%d",&arr[i]);      
   }
   printf("elements' sorting process started\n");
   for(i=0;i<size;i++)
   {

        arra2_rep=0;
       for(j=i+1;j<size;j++)
        {
           if(arr[i]==arr[j])
             {
                 arra2_rep++;
                 arr1[i]=arra2_rep;
             }
       }
}
printf("repeated numbers are\n");
for(i=0;i<size;i++)
   {                            
     printf("number=%d and repeated times=%d\n",arr[i],arr1[i]);      
   }
return 0;

}

Write a program to show initialization of element in an array

using turbo c++
--------------------------------------------------------------------------------------------------
//Write a program to show initialization of element in an array
#include<stdio.h>
#include<conio.h>
void main()
{
float arr[4]={1,2,3,4},k;                                                                        // array declaration with 4 elements
                                                                                                         // can also be written as arr[]
printf("elements are\n");
for(k=0;k<=3;k++)
{
   printf(" element for location=%d is\n",k);                               // for elements in particular location
   printf("%f",arr[k]);
}
getch();
}

------------------------------------------------------------------------------------------------------------------------------------------

using codeblocks or dev c++/online compiler
---------------------------------------------------------------------------------------------------------------------------------------
//Write a program to show initialization of element in an array

#include<stdio.h>
int main()
{
float arr[4]={1,2,3,4},k;                                                                        // array declaration with 4 elements
                                                                                                         // can also be written as arr[]
printf("elements are\n");
for(k=0;k<=3;k++)
{
   printf(" element for location=%d is\n",k);                               // for elements in particular location
   printf("%f",arr[k]);
}
return 0;
}

WAP to search an element stored in an array.



using turbo c++
----------------------------------------------------------------------------------------------------------
// program to search an element in an array

#include <stdio.h>
#include<conio.h>
void main()
{
    int a[100],n,i,number,location,j,found;
    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 search, are:\n");
    for(i=0;i<n;i++)
    {
        printf("%d\n",a[i]);
    }
    printf("enter number  to be searched\n");
    scanf("%d",&number);
    for(i=0;i<n;i++)
    {
        if(number==a[i])
        {
            found=0;
            break;
        }
        else
        {
            found=1;
        }
    }
    if(found==0)
    {
    printf("number found and number %d location is %d\n",number,i);
    }
    else
    {
        printf("given number is not in the list");
    }
    getch();
}

-----------------------------------------------------------------------------------------------------------------
using codeblocks/dev c++/online compiler
----------------------------------------------------------------------------------------------------------------
// program to search an element in an array

#include <stdio.h>

int main()
{
    int a[100],n,i,number,location,j,found;
    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 search, are:\n");
    for(i=0;i<n;i++)
    {
        printf("%d\n",a[i]);
    }
    printf("enter number's  to be searched\n");
    scanf("%d",&number);
    for(i=0;i<n;i++)
    {
        if(number==a[i])
        {
            found=0;
            break;
        }
        else
        {
            found=1;
        }
    }
    if(found==0)
    {
    printf("number found and number %d location is %d\n",number,i);
    }
    else
    {
        printf("given number is not in the list");
    }
    return 0;

}

program to count total positive elements among 'n' elements.

using turbo C++
-----------------------------------------------------------------------
// program to count total positive elements among 'n' elements.
#include <stdio.h>
#include<conio.h>
void main()
{
    int a[100],n,i,count=0;
    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]>0)
                {
                   count++;
                 }
    }
 printf("total positive elements is=%d",count);
    getch();
}
-------------------------------------------------------------------------------------------------------------------
using online compiler/devC++/codeblocks with return concept
---------------------------------------------------------------------------------------------------------------------
// program to count total positive elements among 'n' elements.
#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]>0)
                {
                   count++;
                 }
    }
       printf("total positive elements is=%d",count);
    return 0;
}

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