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

C Array Operations and Examples

The document discusses arrays in C including static and dynamic allocation, taking elements as input, and displaying elements. It also provides examples of programs to take array elements, find the largest and smallest element, calculate sum and average, and count frequencies.

Uploaded by

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

C Array Operations and Examples

The document discusses arrays in C including static and dynamic allocation, taking elements as input, and displaying elements. It also provides examples of programs to take array elements, find the largest and smallest element, calculate sum and average, and count frequencies.

Uploaded by

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

Array

Array

int Arr[5]; Arr variable stores 5 integer values.


float Arr[5]; Arr variable stores 5 float values.
Array
Array
Array
We can take elements in array using two ways:
• Static way
• Dynamic way (using malloc function)
Array (Static Way)
Write a program in C to take elements in Array in static way and
display them .
Array (Dynamic Way)
#include<stdio.h> for(i=0; i<n; i++)
#include<stdlib.h> {
int main() printf("\n Enter an integer");
{ scanf("%d", ptr+1);
int i, n; }
printf("Enter the number of integers"); for(i=0;i<n;i++)
scanf("%d", &n); {
int *ptr=(int *)malloc(n*sizeof(int)); printf("%d", *(ptr+i));
return 0;
if(ptr==NULL) }
{ }
printf("Memory not available");
exit(1);
}
List to do
[Link] in C to take elements in an array and display them.

[Link] in C to take find the largest and smallest element of an array.

[Link] in C to find the sum and average of all the elements of an array.

[Link] in C to count the frequency of a particular element in an aray.

You might also like