ARRAY = It is the collection of similar types of data.
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 :
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;
}
Comments
Post a Comment