Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main(){
- int a[100],n,loc,element,i;
- printf("Enter the number of ELement: ");
- scanf("%d",&n);
- printf("Enter the ELements of Array: ");
- for(i=0;i<n;i++){
- scanf("%d",&a[i]);
- }
- printf("a[%d]: ",n);
- for(i=0;i<n;i++){
- printf("%d ",a[i]);
- }
- printf("\nEnter the element you want to insert: ");
- scanf("%d", &element);
- printf("Enter the location in which you want to insert: ");
- scanf("%d", &loc);
- for(i=n-1;i>=loc;i--){
- a[i+1]=a[i];
- }
- a[loc]=element;
- n=n+1;
- printf("New Array,a[%d]: ",n);
- for(i=0;i<n;i++){
- printf("%d ",a[i]);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement