Array is a very important concept that we use in C . Basically it is a sequence of a data items of homogeneous values. Array as 1D is a base of whole array.
For sake of beginners here a simple program on array.
/* Pre- Processor used throughout the program*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 15 /* Length specified for MAX*/
void main()
{
int i, num, array[MAX];
clrscr();
printf("\nEnter no of element you want to insert in array: ");
scanf("%d",&num);
for(i=0;i<num;i++)
{
printf("\nEnter a value:- ");
scanf("%d",&array[i]);
}
for(i=0;i<num;i++)
{
printf("\nOutput:- %d",array[i]);
}
getch();
}
For sake of beginners here a simple program on array.
/* Pre- Processor used throughout the program*/
#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#define MAX 15 /* Length specified for MAX*/
void main()
{
int i, num, array[MAX];
clrscr();
printf("\nEnter no of element you want to insert in array: ");
scanf("%d",&num);
for(i=0;i<num;i++)
{
printf("\nEnter a value:- ");
scanf("%d",&array[i]);
}
for(i=0;i<num;i++)
{
printf("\nOutput:- %d",array[i]);
}
getch();
}
No comments:
Post a Comment