User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C section within the Software Development category of DaniWeb, a massive community of 455,985 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,759 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C advertiser: Programming Forums
Views: 571 | Replies: 8
Reply
Join Date: Dec 2007
Posts: 5
Reputation: devilofangel is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
devilofangel devilofangel is offline Offline
Newbie Poster

I Really Need Your Help Pls!

  #1  
Dec 4th, 2007
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!...
Last edited by devilofangel : Dec 4th, 2007 at 1:05 pm. Reason: lack of info
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 5
Reputation: devilofangel is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
devilofangel devilofangel is offline Offline
Newbie Poster

Re: I Really Need Your Help Pls!

  #2  
Dec 4th, 2007
#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]);
}
}
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: I Really Need Your Help Pls!

  #3  
Dec 4th, 2007
Well there's this - http://www.daniweb.com/forums/announcement118-3.html
So that people might care enough to look at your code rather than just dismissing it as an unreadable mess.
Reply With Quote  
Join Date: Mar 2005
Location: Phnom Penh, Cambodia
Posts: 415
Reputation: invisal will become famous soon enough invisal will become famous soon enough 
Rep Power: 5
Solved Threads: 36
invisal's Avatar
invisal invisal is offline Offline
Posting Pro in Training

Re: I Really Need Your Help Pls!

  #4  
Dec 4th, 2007
Please make your code readable by using <code=cpp>your code</code>. Change from < to [ and > to ]
Last edited by invisal : Dec 4th, 2007 at 2:26 pm.
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Reply With Quote  
Join Date: Mar 2005
Location: Phnom Penh, Cambodia
Posts: 415
Reputation: invisal will become famous soon enough invisal will become famous soon enough 
Rep Power: 5
Solved Threads: 36
invisal's Avatar
invisal invisal is offline Offline
Posting Pro in Training

Re: I Really Need Your Help Pls!

  #5  
Dec 4th, 2007
Anyway, I have made your code clean so more people will more interesting in helping you. I am sleepy now. Good night!

  1. #include<stdio.h>
  2. #include<conio.h>
  3. #define MAX_LEN 100
  4.  
  5. void display (int*,int);
  6.  
  7. void main()
  8. {
  9. int num[MAX_LEN];
  10. int i, input, op;
  11. char ch;
  12.  
  13. clrscr();
  14.  
  15. printf("\tMenu");
  16. 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");
  17. printf("\nEnter Element: " ); scanf("%d", &input);
  18.  
  19. do {
  20. printf("\nChoose Operation: ");
  21. scanf("%d",&op);
  22. } while(op!=5); //after this i really dont know what to do
  23.  
  24. //can someone help me with this?.. pls!
  25. getch();
  26. }
  27.  
  28. void display(int*arr,int index)
  29. {
  30. int i;
  31. for(i=0;i<=index;i++) {
  32. printf("%d",arr[i]);
  33. }
  34. }
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Reply With Quote  
Join Date: Dec 2005
Posts: 3,834
Reputation: Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of Salem has much to be proud of 
Rep Power: 23
Solved Threads: 436
Colleague
Salem's Avatar
Salem Salem is offline Offline
banned

Re: I Really Need Your Help Pls!

  #6  
Dec 4th, 2007
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).
Reply With Quote  
Join Date: Mar 2005
Location: Phnom Penh, Cambodia
Posts: 415
Reputation: invisal will become famous soon enough invisal will become famous soon enough 
Rep Power: 5
Solved Threads: 36
invisal's Avatar
invisal invisal is offline Offline
Posting Pro in Training

Re: I Really Need Your Help Pls!

  #7  
Dec 4th, 2007
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.
Last edited by invisal : Dec 4th, 2007 at 3:10 pm.
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Reply With Quote  
Join Date: Dec 2007
Posts: 5
Reputation: devilofangel is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
devilofangel devilofangel is offline Offline
Newbie Poster

Re: I Really Need Your Help Pls!

  #8  
Dec 6th, 2007
guys... i got the code of this already!.. thanks!..
and sorry for the post, it lacks information!...
but, now i get it!...
Reply With Quote  
Join Date: Oct 2006
Location: India
Posts: 514
Reputation: Jishnu will become famous soon enough Jishnu will become famous soon enough 
Rep Power: 5
Solved Threads: 25
Jishnu's Avatar
Jishnu Jishnu is offline Offline
Posting Pro

Re: I Really Need Your Help Pls!

  #9  
Dec 8th, 2007
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.
"You know you're a computer geek when you try to shoo a fly away from the monitor screen with your cursor. That just happened to me. It was scary." - Juuso Heimonen.

"The only truly secure computer is one buried in concrete, with the power turned off and the network cable cut." - Anonymous.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C Forum

All times are GMT -4. The time now is 9:28 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC