0% found this document useful (0 votes)
7 views2 pages

Array Operations in C Programming

The document contains four C programs demonstrating basic array operations. The first program reads and displays ages, the second finds the smallest element in an array, the third performs a linear search for a key element, and the fourth sorts numbers in ascending order. Each program includes user input and output functionalities.

Uploaded by

kavanronald
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Array Operations in C Programming

The document contains four C programs demonstrating basic array operations. The first program reads and displays ages, the second finds the smallest element in an array, the third performs a linear search for a key element, and the fourth sorts numbers in ascending order. Each program includes user input and output functionalities.

Uploaded by

kavanronald
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

[Link].

c
#include<stdio.h>
void main()
{
int i;
int age[1000];
printf("read age array 5 elements");
for(i=0;i<5;i++)
scanf("%d",&age[i]);
printf("display age array elements\n");
for(i=0;i<5;i++)
printf("%d\t",age[i]);
printf("display age array elements in reversed order\n");
for(i=4;i>=0;i--)
printf("%d\t",age[i]);
}

[Link].c
#include<stdio.h>
void main()
{
int num[50];
int i,n,minvalue;
printf("how many element or nos. want to enter in the array
num\n");
scanf("%d",&n);
printf("enter the lements one by one\n");
for(i=0; i<n;i++)
scanf("%d",&num[i]);
minvalue=num[0];
for(i=0;i<n;i++)
{
if(num[i]<minvalue)
{
minvalue=num[i];
}
}
printf("the smallest element is\n");
printf("%d",minvalue);

}
[Link].c
#include<stdio.h>
void main()
{
int array[20], n,key,i;
printf("enter the number of elements n\n");
scanf("%d",&n);
printf("enter the elements one by one\n");
for(i=0;i<n; i++)
scanf("%d",&array[i]);
printf("enter the key element to be searched\n");
scanf("%d",&key);
for(i=0;i<n;i++)
{
if(key==array[i])
{
printf("key element found\n");
printf("in the position of an array%d",i+1);
break;
}
}
}

4. SortNumByAscending.c
#include<stdio.h>
void main()
{
int i, j, temp, n, array[100];
printf("Enter the value of N \n");
scanf("%d", &n);
printf("Enter the numbers \n");
for (i = 0; i < n; i++)
scanf("%d", &array[i]);
for (i = 0; i < n; i++)
{
for (j = i + 1; j < n; j++)
{
if (array[i] > array[j])
{
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
}
}
printf("The numbers arranged in ascending order are given below
\n");
for (i = 0; i < n; i++)
printf("%d\t", array[i]);
}

You might also like