Write a program to insert elements in Array. |
---|
Array is the collection of homogeneous (Similar) datatype. For example Array of integer, float, char, etc. Basic syntax of 1-dimension array in c programming is <DATATYPE> <Array_name>[<array size>]; int A[10]; Array is linear data type which store the data in a linear sequence. First element of array is store at the 0th position of array like A[0] and last element of array store at position of nth-1. like 10th element store at 9th position in array. |
Source code: |
#include<stdio.h> void main() { int A[50],n,i; clrscr(); printf("Enter no of element you want::"); scanf("%d",&n); for(i=0;i<n;i++) { printf("%d element : ",i+1); scanf("%d",&A[i]); } printf("\nElement you enter:\n"); for(i=0;i<n;i++) { printf("%d\t",A[i]); } getch(); } |
Output: |
Related Post
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment