954,500 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

help me in array

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

#include<stdio.h>

 main()

{
    int i,Number[5];

    for (i=0; i<5; i++)
    
    {
        printf("Enter Number:    ");
        scanf("%d" ,&Number[i]);


    }


    for (i=0; i<5; i++)
    {
    
        printf("%d\t" ,Number[i]);

    }

    printf("\n");
            
    for(i=4; i>=0; i--)
    {

        printf("%d\t", Number[i]);


    }
    

}


help me to find the wrong

ting_ting
Newbie Poster
2 posts since Oct 2008
Reputation Points: 10
Solved Threads: 0
 

Hi its sth simple:

int main()
{

....
return 0;
}
sidatra79
Junior Poster
114 posts since Feb 2008
Reputation Points: 46
Solved Threads: 8
 

post the error message(s)

line 3: should be int main() -- functions require a return type.

Ancient Dragon
Retired & Loving It
Team Colleague
30,049 posts since Aug 2005
Reputation Points: 5,662
Solved Threads: 2,343
 

abov e program can also be written as:

void main()
{
------
-----
getch();
}
ajay.krish123
Junior Poster in Training
90 posts since Nov 2008
Reputation Points: 6
Solved Threads: 9
 

abov e program can also be written as:

void main()
{
------
-----
getch();
}


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 bemore completely wrong is to introduce syntax errors into one of the four "this is real code" lines of that example.

Narue
Bad Cop
Administrator
15,460 posts since Sep 2004
Reputation Points: 6,464
Solved Threads: 1,401
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You