fix the error in this code.  #include int insert(int *); int display(int *); int del(int *); void main() {     int a[100];

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

 

fix the error in this code. 

#include<stdio.h>

int insert(int *);

int display(int *);

int del(int *);

void main()

{

    int a[100];

    int ch;

    while(1)

    {

    {

      printf("-------Menu-------");

    printf("\nEnter 1 to insert element in array:\t");

    printf("\nEnter 2 to display element in array:\t");

    printf("\nEnter 3 to Delete element in array:\t");

    printf("\nEnter 4 to Exit:\t");

    printf("\n enter the choice \n");

    scanf("%d",&ch);

    switch(ch)

    {

        case 1:insert(a);

                    break;

        case 2:display(a);

                    break;

        case 3:del(a);

                    break;

        case 4:exit(0);

    }

    }

    }

 

}

int insert(int *a)

{

    int i,n;

    printf("Enter the no. of elements in array:\t");

    scanf("%d",&n);

    printf("\nEnter %d elements in array:\t",n);

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

    {

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

    }

    a[i]='\0';

    return *a;

}

int display(int *a)

{

    int j;

    for(j=0;a[j]!=NULL;j++)

    {

        printf("\nElement of array=%d",a[j]);

    }

    return *a;

}

int del(int *a)

{

    int c,k,posi;

    for(k=0;a[k]!=NULL;k++)

    {

    }

    printf("Enter the position to delete element:\t");

    scanf("%d",&posi);

    if(posi<=k)

    {

        for(c=posi-1;c<k-1;c++)

        {

            a[c]=a[c+1];

        }

        printf("\nArray after Deletion");

        for(c=0;c<k-1;c++)

        {

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

        }

    }

    return *a;

}

for (i=0;i<n;i++)
{
scanf("%d",&a[i]);
}
a[i]='\0';
return *a;
}
int display(int *a)
{
int j;
for (j=0;a[j]! =NULL;j++)
{
printf("\nElement of array=%d" ,a[j]);
}
return *a;
}
int del(int *a)
{
int c,k,posi;
for (k=0; a[k]!=NULL;k++)
{
}
printf("Enter the position to delete
element:\t");
scanf("%d",&posi);
if(posi<=k)
{
for(c=posi-1;c<k-1;c++)
{
a[c]=a[c+1];
}
printf("\nArray after Deletion");
for (c=0;c<k-1;c++)
{
printf("\n%d",a[c]);
}
}
return *a;
}
Transcribed Image Text:for (i=0;i<n;i++) { scanf("%d",&a[i]); } a[i]='\0'; return *a; } int display(int *a) { int j; for (j=0;a[j]! =NULL;j++) { printf("\nElement of array=%d" ,a[j]); } return *a; } int del(int *a) { int c,k,posi; for (k=0; a[k]!=NULL;k++) { } printf("Enter the position to delete element:\t"); scanf("%d",&posi); if(posi<=k) { for(c=posi-1;c<k-1;c++) { a[c]=a[c+1]; } printf("\nArray after Deletion"); for (c=0;c<k-1;c++) { printf("\n%d",a[c]); } } return *a; }
1 #include<stdio.h>
int insert(int *);
3 int display(int *);
int del(int *);
5 void main()
4
6- {
7
int a[100];
8
int ch;
9
while(1)
10 -
{
11 -
{
printf("-------Menu-------");
printf("\nEnter 1 to insert element in
12
13
array:\t");
printf("\nEnter 2 to display element in
14
array:\t");
printf("\nEnter 3 to Delete element in
array:\t");
printf("\nEnter 4 to Exit:\t");
printf("\n enter the choice \n");
scanf("%d",&ch);
switch(ch)
15
16
17
18
19
20 -
{
21
case 1:insert(a);
22
break;
case 2:display(a);
break;
23
24
case 3:del(a);
break;
25
26
27
case 4:exit(0);
28
}
29
}
30
}
31
32
}
33
int insert(int *a)
34 - {
35
int i,n;
36
printf("Enter the no. of elements in array
:\t");
scanf("%d",&n);
printf("\nEnter %d elements in array:\t",n
37
38
);
39
for (i=0;i<n;i++)
40 -
{
41
scanf("%d",&a[i]);
42
}
43
a[i]='\0';
44
return *a;
45
}
int display(int *a)
47 - {
46
48
int j;
49
for(j=0;a[j]!=NULL;j++)
50 -
{
51
printf("\nElement of array=%d", a[j]);
52
}
53
return *a;
54
}
55 int del(int *a)
56 - {
int c,k,posi;
for (k=0;a[k]!=NULL;k++)
57
58
59 -
{
60
}
printf("Enter the position to delete
element:\t");
scanf("%d",&posi);
if(posi<=k)
61
62
63
64 -
{
65
for (c=posi-1;c<k-1;c++)
66 -
{
67
a[c]=a[c+1];
68
}
printf("\nArray after Deletion");
for (c=0;c<k-1;c++)
69
70
Transcribed Image Text:1 #include<stdio.h> int insert(int *); 3 int display(int *); int del(int *); 5 void main() 4 6- { 7 int a[100]; 8 int ch; 9 while(1) 10 - { 11 - { printf("-------Menu-------"); printf("\nEnter 1 to insert element in 12 13 array:\t"); printf("\nEnter 2 to display element in 14 array:\t"); printf("\nEnter 3 to Delete element in array:\t"); printf("\nEnter 4 to Exit:\t"); printf("\n enter the choice \n"); scanf("%d",&ch); switch(ch) 15 16 17 18 19 20 - { 21 case 1:insert(a); 22 break; case 2:display(a); break; 23 24 case 3:del(a); break; 25 26 27 case 4:exit(0); 28 } 29 } 30 } 31 32 } 33 int insert(int *a) 34 - { 35 int i,n; 36 printf("Enter the no. of elements in array :\t"); scanf("%d",&n); printf("\nEnter %d elements in array:\t",n 37 38 ); 39 for (i=0;i<n;i++) 40 - { 41 scanf("%d",&a[i]); 42 } 43 a[i]='\0'; 44 return *a; 45 } int display(int *a) 47 - { 46 48 int j; 49 for(j=0;a[j]!=NULL;j++) 50 - { 51 printf("\nElement of array=%d", a[j]); 52 } 53 return *a; 54 } 55 int del(int *a) 56 - { int c,k,posi; for (k=0;a[k]!=NULL;k++) 57 58 59 - { 60 } printf("Enter the position to delete element:\t"); scanf("%d",&posi); if(posi<=k) 61 62 63 64 - { 65 for (c=posi-1;c<k-1;c++) 66 - { 67 a[c]=a[c+1]; 68 } printf("\nArray after Deletion"); for (c=0;c<k-1;c++) 69 70
Expert Solution
steps

Step by step

Solved in 5 steps with 6 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY