By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,132 Members | 1,948 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,132 IT Pros & Developers. It's quick & easy.

Question on array?

P: 24
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include<stdio.h>
  3. #define N_ELEMS 5
  4. void main(void)
  5. {
  6.     int array[N_ELEMS];
  7.     int i;
  8.  
  9.     for(i=0;i<N_ELEMS;i++)
  10.         array[i]=i;
  11.  
  12.     for(i=0;i<N_ELEMS-1;)
  13.         array[++i]++;
  14. }    
Nov 7 '06 #1
Share this Question
Share on Google+
3 Replies


P: 6
looks like you don't have any output.
Nov 7 '06 #2

10K+
P: 13,264
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

Expand|Select|Wrap|Line Numbers
  1.  
  2. #include<stdio.h>
  3. #define N_ELEMS 5
  4. void main(void)
  5. {
  6.     int array[N_ELEMS];
  7.     int i;
  8.  
  9.     for(i=0;i<N_ELEMS;i++)
  10.         array[i]=i;
  11.  
  12.     for(i=0;i<N_ELEMS-1;)
  13.         array[++i]++;
  14. }    
Your program has no statement that sends output to the screen. You need to use a printf to print something to the screen.
Nov 7 '06 #3

emaghero
P: 85
Use
Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<ELEMS;i++){
  2. cout<<array[i]<<endl;
  3. }
in C++
Or
Expand|Select|Wrap|Line Numbers
  1. for(int i=0;i<ELEMS;i++){
  2. printf("%e\n",array[i])
  3. }
Nov 8 '06 #4

Post your reply

Sign in to post your reply or Sign up for a free account.