Thread: could anyonw help me in an array program

  1. #1
    Registered User
    Join Date
    Mar 2002

    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];
    for (j=i+1; j<=n ; j++)
    if (min > E[i])
    min= E[i] ;
    minInd= j ;

    E[minInd]=E[i] ;

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


  2. #2
    Join Date
    Feb 2002
    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 - It's what your PC is made for!

  3. #3
    &TH of undefined behavior Fordy's Avatar
    Join Date
    Aug 2001
    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#...


    >>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, 03: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, 01:01 AM
  5. Struct *** initialization
    By Saravanan in forum C Programming
    Replies: 20
    Last Post: 10-09-2003, 12:04 PM