Friday 10 July 2020

Element delete program from array | C Language

Q :  Write a program that accept an array of 10 integers and a number to be deleted from the array if found. Represent deleted element with -1 and display final array. If not found print appropriate message.


Answer :

#include<stdio.h>
#include<conio.h>
/*============================
     Girfa Student Help
     Delete operation in array
==============================*/
void main()
{

     int ar[10],i,n;
     clrscr();
     for(i=0;i<10;i++)
     {
           printf("Enter number for %d position>> ",i+1);
           scanf("%d",&ar[i]);
     }
     printf("Enter number for search>> ");
     scanf("%d",&n);
     for(i=0;i<10;i++)
     {
           if(ar[i]==n)
                break;
     }
     if(i==10)
           printf("Search No. for found");
     else
     {
           ar[i]=-1;
           /* printing array */
           for(i=0;i<10;i++)
                printf("\t%d",ar[i]);
     }
     getch();

}



1 comment:

  1. nice work, I am getting most of the answers to my questions of O level

    ReplyDelete