Skip to content

Instantly share code, notes, and snippets.

@devils-ey3
Created September 21, 2016 11:13
Show Gist options
  • Save devils-ey3/79dfef7446993a265daa5451688d07a5 to your computer and use it in GitHub Desktop.
Save devils-ey3/79dfef7446993a265daa5451688d07a5 to your computer and use it in GitHub Desktop.
Delete a number from an array
#include <stdio.h>
int main ()
{
int array [100];
int maxi_index,j;
scanf("%d",&maxi_index);
array [maxi_index];
for (j=0;j<maxi_index;j++)
scanf("%d",&array [j]);
int read_value,read_index;
// printf("Give value : ");
// scanf("%d",&read_value);
printf("Give the index number : ");
scanf("%d",&read_index);
if (read_index>=maxi_index)
{
maxi_index--;
}
else
{
for (j=read_index;j<maxi_index;j++)
{
array[j-1]=array[j];
}
maxi_index--;
}
for (j=0;j<maxi_index;j++)
printf("%d ",array[j]);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment