Input output operation with array:
#include<stdio.h>
int main()
int a[5],i;
printf("enter elements of the array");
for(i=0;i<5;i++)
printf("enter data");
scanf("%d",&a[i]);
for(i=0;i<5;i++)
printf("\n%d",a[i]);
return 0;
Sum of even elements:
#include<stdio.h>
int main()
int a[5],i,sum=0;
printf("enter elements of the array");
for(i=0;i<5;i++)
printf("enter data");
scanf("%d",&a[i]);
for(i=0;i<5;i++)
if(a[i]%2==0)
sum=sum+a[i];
printf("\n%d",sum);
return 0;
Linear search:
#include<stdio.h>
int main()
int a[5],i,n,flag=0;
printf("enter elements of the array");
for(i=0;i<5;i++)
{
printf("enter data");
scanf("%d",&a[i]);
printf("enter data to be searched for");
scanf("%d",&n);
for(i=0;i<5;i++)
if(a[i]==n)
flag=1;
break;
if(flag==1)
printf("item found");
else
printf("item not found");
return 0;
Minimum and maximum:
#include<stdio.h>
int main()
int a[5],i,max,min;
printf("enter elements of the array");
for(i=0;i<5;i++)
printf("enter data");
scanf("%d",&a[i]);
max=a[0];
for(i=1;i<5;i++)
if(max<a[i])
max=a[i];
printf("maximum element is=%d",max);
min=a[0];
for(i=1;i<5;i++)
if(min>a[i])
min=a[i];
printf("minimum element is=%d",min);
return 0;
Reversing array elements:
#include<stdio.h>
int main()
int a[5],i,j,temp;
printf("enter elements of the array");
for(i=0;i<5;i++)
printf("enter data");
scanf("%d",&a[i]);
for(i=0,j=4;i<=j;i++,j--)
temp=a[i];
a[i]=a[j];
a[j]=temp;
}
printf("\nafter reversing elements");
for(i=0;i<5;i++)
printf("\n%d",a[i]);
return 0;
Append array in another array:
#include<stdio.h>
int main()
int a[50],b[50],i,j,n,m;
printf("\nhow many elements in the 1st array");
scanf("%d",&n);
for(i=0;i<n;i++)
printf("enter data");
scanf("%d",&a[i]);
printf("\nhow many elements in the 2nd array");
scanf("%d",&m);
for(i=0;i<m;i++)
printf("enter data");
scanf("%d",&b[i]);
for(i=n,j=0;j<m;i++,j++)
a[i]=b[j];
for(i=0;i<n+m;i++)
printf("%d",a[i]);
return 0;