943,621 Members | Top Members by Rank

Ad:
  • C Discussion Thread
  • Unsolved
  • Views: 565
  • C RSS
Nov 7th, 2008
0

help me in array

Expand Post »
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
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
ting_ting is offline Offline
2 posts
since Oct 2008
Nov 7th, 2008
0

Re: help me in array

Hi its sth simple:

c++ Syntax (Toggle Plain Text)
  1. int main()
  2. {
  3.  
  4. ....
  5. return 0;
  6. }
Reputation Points: 46
Solved Threads: 8
Junior Poster
sidatra79 is offline Offline
114 posts
since Feb 2008
Nov 7th, 2008
0

Re: help me in array

post the error message(s)

line 3: should be int main() -- functions require a return type.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,947 posts
since Aug 2005
Nov 12th, 2008
0

Re: help me in array

abov e program can also be written as:
  1. void main()
  2. {
  3. ------
  4. -----
  5. getch();
  6. }
Reputation Points: 6
Solved Threads: 9
Junior Poster in Training
ajay.krish123 is offline Offline
90 posts
since Nov 2008
Nov 12th, 2008
1

Re: help me in array

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.
Administrator
Reputation Points: 6442
Solved Threads: 1393
Bad Cop
Narue is offline Offline
11,807 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C Forum Timeline: Returning counters to 0 ?
Next Thread in C Forum Timeline: pointers to function





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC