Question on array?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • cool17
    New Member
    • Oct 2006
    • 24

    Question on array?

    Hi when i run the code it did not show me anything, is there anything that i had missed out or what? Thank for the help

    Code:
    #include<stdio.h>
    #define N_ELEMS 5
    void main(void)
    {
    	int array[N_ELEMS];
    	int i;
    	
    	for(i=0;i<N_ELEMS;i++)
    		array[i]=i;
    	
    	for(i=0;i<N_ELEMS-1;)
    		array[++i]++;
    }
  • ipazman420
    New Member
    • Nov 2006
    • 6

    #2
    looks like you don't have any output.

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by cool17
      Hi when i run the code it did not show me anything, is there anything that i had missed out or what? Thank for the help

      Code:
       
      #include<stdio.h>
      #define N_ELEMS 5
      void main(void)
      {
      	int array[N_ELEMS];
      	int i;
       
      	for(i=0;i<N_ELEMS;i++)
      		array[i]=i;
       
      	for(i=0;i<N_ELEMS-1;)
      		array[++i]++;
      }
      Your program has no statement that sends output to the screen. You need to use a printf to print something to the screen.

      Comment

      • emaghero
        New Member
        • Oct 2006
        • 85

        #4
        Use
        Code:
        for(int i=0;i<ELEMS;i++){
        cout<<array[i]<<endl;
        }
        in C++
        Or
        Code:
        for(int i=0;i<ELEMS;i++){
        printf("%e\n",array[i])
        }

        Comment

        Working...