i am new at programming basic.. i got this problem at school... i want to seek help from you!..its all about inserting and deleting arrays in c language!.. im really confused about the code of this...pls help me!...
for example:
given this output:

Menu Operations:
[1]Insert at beginning
[2]Insert at middle
[3]Insert at End
[4]Show array elements
[5]Delete array elements
[6]Exit

Enter element u want to insert:_ //first u need to enter a first value
Enter your choice of operation?:_ //what operaton you will used..

Enter element u want to insert: _ //need to enter another value
Enter your choice of operation: _ //operation again..

Enter element u want to insert: _ //need to enter another value
Enter your choice of operation: _ //operation again..

//the Output would display the arrays showing every operation you made

eg...
//you enter a value of 1 in the first element and the second is 2 and the third is 3...
//when u choose operation #3 the output would be...

1 2 3

//and so on the other operations....pls help me!... i really need your help!
//thanks!...

Recommended Answers

All 8 Replies

#include<stdio.h>
#include<conio.h>
#define MAX_LEN 100
void display (int*,int);
void main()
{
    int num[MAX_LEN];
    int i, input, op;
    char ch;
    clrscr();
    printf("\tMenu");
    printf("\n[1]Insert at beginning\n[2]Insert at middle\n[3]Insert at end\n[4]Show Array elements\n[5]Delete array element\n[6]Exit");
    printf("\nEnter Element: " );scanf("%d",& input);
    do{
        printf("\nChoose Operation: ");
        scanf("%d",&op);
        }while(op!=5);                 //after this i really dont know what to do 

                                                                      //can someone help me with this?.. pls!






getch();
}
void display(int*arr,int index)
{
    int i;
    for(i=0;i<=index;i++)
        {
                printf("%d",arr[i]);
        }
}

Please make your code readable by using <code=cpp>your code</code>. Change from < to [ and > to ]

Anyway, I have made your code clean so more people will more interesting in helping you. I am sleepy now. Good night!

#include<stdio.h>
#include<conio.h>
#define MAX_LEN 100

void display (int*,int);

void main()
{
    int num[MAX_LEN];
    int i, input, op;
    char ch;
    
    clrscr();
    
    printf("\tMenu");
    printf("\n[1]Insert at beginning\n[2]Insert at middle\n[3]Insert at end\n[4]Show Array elements\n[5]Delete array element\n[6]Exit");
    printf("\nEnter Element: " ); scanf("%d", &input);
    
    do {
        printf("\nChoose Operation: ");
        scanf("%d",&op);
    } while(op!=5); //after this i really dont know what to do

    //can someone help me with this?.. pls!
    getch();
}

void display(int*arr,int index)
{
    int i;
    for(i=0;i<=index;i++) {
        printf("%d",arr[i]);
    }
}

Not bad, apart from
- void main
- using conio.h
- using clrscr()
- using getch()

> for(i=0;i<=index;i++)
It should be <, not <= if you want to count 'index' elements (you start at 0, not 1).

I still don't understand what are you trying to. There are 6 operators; first operator is for insert at the beginning. The beginning is refer to the first element of array. For example: firstly, I used [1] operator which insert a value into the first element of array. Then I decided to use that operator again, so I will insert a value into first element of array again? I still don't get it.

guys... i got the code of this already!.. thanks!..
and sorry for the post, it lacks information!...
but, now i get it!...

A peice of humble advice for devilofangel

You may have not known this before but it is considered (very truelly so) a malpractice and a cheap way to increase the no. of posts to post content in multiple posts. I learned this the harder way by losing my reputation. So I thought that I must inform you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.