#include<stdio.h> #include<conio.h> void main() { int a[20],i,pos,ele,n; clrscr(); printf("enter n:"); scanf("%d",&n); printf("elements %d:",n); for(i=0;i<n;i++) scanf("%d",&a[i]); printf("val and pos:"); scanf("%d%d",&ele,&pos); for(i=n;i>pos;i--) { a[i]=a[i-1]; } a[pos]=ele; for(i=0;i<=n;i++) printf("%d ",a[i]); getch(); }
C Program To Insert an element in the array
January 02, 2015
By:
Bhanu Namikaze
Bhanu Namikaze
Bhanu Namikaze is an Ethical Hacker, Security Analyst, Blogger, Web Developer and a Mechanical Engineer. He Enjoys writing articles, Blogging, Debugging Errors and Capture the Flags. Enjoy Learning; There is Nothing Like Absolute Defeat - Try and try until you Succeed.
No comments:
Post a Comment