Answer to Question #210895 in C for genji 3

Question #210895

Design a C program to insert an element in a specified position in the given array.


1
Expert's answer
2021-06-27T14:09:45-0400
#include <conio.h>
#include<stdio.h>
 
 
 display(int array[],int j)
 { 
    int n;
    for(n=0; n<j; n++)
    {
         
        printf("%d ",array[n]);
         
    }
 	
 }
int main()
{
    int array[4];
	int i;
	int n;
	int index;
	int new1;
   
    
 
    printf("Enter items in array : ");
    for(n=0; n<4; n++)
    {
        scanf("%d",&array[i]);
    }
    
	printf("Index must not exceed %d:",n);
    scanf("%d",&index);
    if(index<n)
    {
 
     printf("New item : ");
     scanf("%d",&new1);
    
     printf("Before  inserting an item :");
     display(array,4);
     array[index]=new1;
     
    printf("\nafter   inserting an item :");
    display(array,n);
    }
    return 0;
} 

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS