DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C (http://www.daniweb.com/forums/forum118.html)
-   -   help me in array (http://www.daniweb.com/forums/thread156000.html)

ting_ting Nov 7th, 2008 8:18 pm
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

sidatra79 Nov 7th, 2008 8:24 pm
Re: help me in array
 
Hi its sth simple:

int main()
{

....
return 0;
}

Ancient Dragon Nov 7th, 2008 8:25 pm
Re: help me in array
 
post the error message(s)

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

ajay.krish123 Nov 12th, 2008 10:06 am
Re: help me in array
 
abov e program can also be written as:
void main()
{
------
-----
getch();
}

Narue Nov 12th, 2008 10:15 am
Re: help me in array
 
Quote:

Originally Posted by ajay.krish123 (Post 734153)
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 be more completely wrong is to introduce syntax errors into one of the four "this is real code" lines of that example.


All times are GMT -4. The time now is 2:03 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC