Upcoming SlideShare
×

# One dimensional operation of Array in C- language

337 views

Published on

Operation on the one dimensional array

Published in: Engineering, Technology, Education
0 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

• Be the first to like this

Views
Total views
337
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
8
0
Likes
0
Embeds 0
No embeds

No notes for slide

### One dimensional operation of Array in C- language

1. 1. //Array operation in C languages. #include<stdio.h> #include<stdlib.h> #include<conio.h> void main() { int a[10]; int i,c; int n; clrscr(); printf("How many values u want to store: "); scanf("%d",&n); printf("Enter the elements"); for(i=0;i<n;i++) scanf("%d",&a[i]); while(1) { printf("Enter ur choice: n1.Insertionn2.Deletionn3.sortingn4.Searchn5.Displayn6.Exit "); scanf("%d",&c); switch(c) { case 1: { int p,item;
2. 2. clrscr(); printf("nEnter the element"); scanf("%d",&item); printf("nEnter the position where u want to insert: "); scanf("%d",&p); for(i=n;i>=p;i--) a[i]=a[i-1]; a[p-1]=item; n++; printf("Element inserted successfully"); break; } case 2:{ int p; clrscr(); printf("nthe elements are"); for(i=0;i<n;i++) printf("%dt",a[i]); printf("nEnter the position where u want to delete: "); scanf("%d",&p); for(i=p;i<n;i++) a[i-1]=a[i]; n--;
3. 3. printf("Element deleted successfully"); break; } case 3: { int i,j,t; for(i=0;i<n-1;i++) for(j=0;j<n-i;j++) { if(a[j]>a[j+1]) { t=a[j+1]; a[j+1]=a[j] ; a[j]=t; } } printf("Element are sorted Successfully."); break; } case 4:{ int item,k=0; clrscr(); printf("Enter the element u want to search: "); scanf("%d",&item); for(i=0;i<n;i++)
4. 4. { if(a[i]==item) { k=i+1; printf("Element is found at %d location",k); } else { i++; } } if(k==0) { printf("Element is not found"); } break; } case 5:{ printf("The value of n=%d",n); printf("nthe elements are"); for(i=0;i<n;i++) printf("%dt",a[i]); break; }
5. 5. case 6: exit(0); } } }