ARRAY.

 ARRAY =  It is the collection of similar types of data. 

//programs

1. Program to copy 1 array into another array

#include<stdio.h>
int main()
{
    int i,j,real[i],n,copy[i];
    printf("enter the size of the array : ");
    scanf("%d",&n);
    printf("enter the value of real array: ");
    for(i=0; i<n; i++)
    {
        scanf("%d",&real[i]);
    }
    for(i=0; i<n; i++)
    {
        copy[i]=real[i];
    }
    printf("copied array value are:");
    for(i=0; i<n; i++)
    {
        printf("%d,",copy[i]);
    }
    return 0;
}

OUTPUT :

enter the size of the array :
7
enter the value of real array: 1
2
3
4
5
6
7
copied array value are:1,2,3,4,5,6,7,
////////////////////////////////////////////////
////

2. Program to find how many duplicate/repeated atoms are present in an given array.

#include<stdio.h>
int main()
{
    int i,j,n,arr[i],count=0;
    printf("enter the size of an array : ");
    scanf("%d",&n);
    printf("Now enter the values of an array = ");
    for(i=0; i<n; i++)
    {
        scanf("%d",&arr[i]);
    }
    for(i=0; i<n; i++)
    {
        for(j=i+1; j<n; j++)
        {
            if(arr[i]==arr[j])
            {
                count++;
                break;
            }
        }
    }
    printf("repeated values are=%d",count);
    return 0;
}

OUTPUT:

enter the size of an array : 7
Now enter the values of an array = 1
2
3
4
2
3
7
repeated values are=2
/////////////////////////////////////////////////////

Comments