help me in array

Reply

Join Date: Oct 2008
Posts: 2
Reputation: ting_ting is an unknown quantity at this point 
Solved Threads: 0
ting_ting ting_ting is offline Offline
Newbie Poster

help me in array

 
0
  #1
Nov 7th, 2008
this is question and the answer...but i cannot compile it in dev c++ correctly..help me

//(a) Get five integer numbers from the user.
//( Store the numbers in an array called Number.
//© Display all the numbers on screen.
//(d) Modify the program so that it prints the reverse of the numbers.


//CONTOH OUTPUT :

//Enter numbers : 1
//Enter numbers : 2
//Enter numbers : 3
//Enter numbers : 4
//Enter numbers : 5


//1 2 3 4 5

//5 4 3 2 1

//Press any key to continue



  1. #include<stdio.h>
  2.  
  3. main()
  4.  
  5. {
  6. int i,Number[5];
  7.  
  8. for (i=0; i<5; i++)
  9.  
  10. {
  11. printf("Enter Number: ");
  12. scanf("%d" ,&Number[i]);
  13.  
  14.  
  15. }
  16.  
  17.  
  18. for (i=0; i<5; i++)
  19. {
  20.  
  21. printf("%d\t" ,Number[i]);
  22.  
  23. }
  24.  
  25. printf("\n");
  26.  
  27. for(i=4; i>=0; i--)
  28. {
  29.  
  30. printf("%d\t", Number[i]);
  31.  
  32.  
  33. }
  34.  
  35.  
  36. }

help me to find the wrong
Last edited by Ancient Dragon; Nov 7th, 2008 at 8:22 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Feb 2008
Posts: 114
Reputation: sidatra79 is an unknown quantity at this point 
Solved Threads: 8
sidatra79's Avatar
sidatra79 sidatra79 is offline Offline
Junior Poster

Re: help me in array

 
0
  #2
Nov 7th, 2008
Hi its sth simple:

  1. int main()
  2. {
  3.  
  4. ....
  5. return 0;
  6. }
"What we repeat defines what we are!!" Aristotle
-->
"looping.. defines Perfomance from O (n) ..up to O(n!)" Sidatra79 :D :D
Reply With Quote Quick reply to this message  
Join Date: Aug 2005
Posts: 15,337
Reputation: Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute Ancient Dragon has a reputation beyond repute 
Solved Threads: 1459
Team Colleague
Featured Poster
Ancient Dragon's Avatar
Ancient Dragon Ancient Dragon is offline Offline
Still Learning

Re: help me in array

 
0
  #3
Nov 7th, 2008
post the error message(s)

line 3: should be int main() -- functions require a return type.
Don't PM me with questions -- you might get a nasty PM in response. If you have a question then post it in one of the forums.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 90
Reputation: ajay.krish123 is an unknown quantity at this point 
Solved Threads: 8
ajay.krish123 ajay.krish123 is offline Offline
Junior Poster in Training

Re: help me in array

 
0
  #4
Nov 12th, 2008
abov e program can also be written as:
  1. void main()
  2. {
  3. ------
  4. -----
  5. getch();
  6. }
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,579
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 709
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: help me in array

 
0
  #5
Nov 12th, 2008
Originally Posted by ajay.krish123 View Post
abov e program can also be written as:
  1. void main()
  2. {
  3. ------
  4. -----
  5. getch();
  6. }
Yes, it can be...if you want your code to be subtly broken and non-portable. The main function returns int by definition. getch isn't a standard function, so you'd be relying on a library extension specific to your compiler.

The only way you could be more completely wrong is to introduce syntax errors into one of the four "this is real code" lines of that example.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC