could anyonw help me in an array program

This is a discussion on could anyonw help me in an array program within the C# Programming forums, part of the General Programming Boards category; Hi all i'm new to cprogramming I'm trying to write a program that should ask as input an array of ...

  1. #1
    Registered User
    Join Date
    Mar 2002
    Posts
    3

    could anyonw help me in an array program

    Hi all
    i'm new to cprogramming
    I'm trying to write a program that should ask as input an array of int and should display the values of that array ordered by decreasing size <
    I cant get the program to work
    Do u think u can help me
    here's my code


    #include <stdio.h>
    #define nb 5
    int i , j , n , min ,minInd;

    void main(void)
    {
    int E[nb] ;

    printf("enter numbers");
    for (i=0; i<5 ; i++)
    {scanf("%d", E[i] );
    min= E[i];
    minInd=i;
    for (j=i+1; j<=n ; j++)
    {
    if (min > E[i])
    min= E[i] ;
    minInd= j ;

    }
    E[minInd]=E[i] ;
    E[i]=min;

    }
    for (i=0; i<5 ; i++)
    printf("%d", E[i]);

    }

  2. #2
    www.entropysink.com
    Join Date
    Feb 2002
    Posts
    605
    I'll say it nicely before someone shoots you down in flames - crossposting (i.e. posting the same question to more than one forum) is considered jolly bad form old chap. Don't do it.

    Give the peeps here a chance to look at your question, let alone answer it.
    Visit entropysink.com - It's what your PC is made for!

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    Posts
    5,789
    Echo above - DONT cross post its really annoying and against baord rules...anyway...this is more of a C question...its relevant to C++ but totally irrelevant to C#...

    Anyway

    >>scanf("%d", E[i] );


    If you have an array of ints, then you must pass the reference of the array member...not the actual value

    scanf("%d", &E[i] );

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Client-server system with input from separate program
    By robot-ic in forum Networking/Device Communication
    Replies: 3
    Last Post: 01-16-2009, 02:30 PM
  2. Array Program
    By alex1067 in forum C Programming
    Replies: 5
    Last Post: 04-15-2008, 06:26 AM
  3. help with small program. array issue
    By InvariantLoop in forum C++ Programming
    Replies: 2
    Last Post: 04-09-2004, 12:26 PM
  4. Type and nontype parameters w/overloading
    By Mr_LJ in forum C++ Programming
    Replies: 3
    Last Post: 01-02-2004, 12:01 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21