0% found this document useful (0 votes)
19 views3 pages

C Array Deletion Example

Uploaded by

parthkudekar101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views3 pages

C Array Deletion Example

Uploaded by

parthkudekar101
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <stdio.

h>

#include <conio.h>

int main() {

int a[5], n = 0, loc, i;

printf("\n Enter how many elements you want to store in the array\n");

scanf("%d", &n);

printf("\n Enter your elements\n");

for (i = 0; i < n; i++) {

scanf("%d", &a[i]);

printf("\n Your elements are:\n");

for (i = 0; i < n; i++) {

printf("\n%d", a[i]);

printf("\n Deletion operation:\n");

printf("\n Enter the location where you want to delete element\n");

scanf("%d", &loc);

if (loc >= n + 1) {

printf("\n Deletion not possible\n");


} else {

for (i = loc - 1; i < n - 1; i++) {

a[i] = a[i + 1];

n--; // Reduce the size of the array as we deleted one element

printf("\n Array after deletion operation:\n");

for (i = 0; i < n; i++) {

printf("\n%d", a[i]);

getch();

You might also like