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.