944,008 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 257
  • C++ RSS
Nov 3rd, 2009
-5

Give me the explanation for this output

Expand Post »
c++ Syntax (Toggle Plain Text)
  1. #include<iostream.h>
  2. #include<conio.h>
  3. void main()
  4. {
  5. int x[5]={1,2,3,4,5},y[5]={5,4,3,2,1},result [5]={0,0,0,0,0};
  6. int i=0;
  7. while(i++ <5)
  8. result[i]=x[i]-y[i];
  9. clrscr();
  10. cout<<"\nThe contents of the array are :\n";
  11. i=0;
  12. do
  13. {
  14. cout<<'\t'<<x[i]<<'\t'<<y[i]<<'\t'<<result [i]<<"\n";
  15. i++;
  16. }while(i<5);
  17. getch();
  18. }
OUTPUT:

The contents of the array are:

1 -1 0
2 4 -2
3 3 0
4 2 2
5 1 4
GIVE ME THE EXPLANATION FOR THIS OUTPUT.
e-mail to <EMAIL SNIPPED>
Last edited by peter_budo; Nov 4th, 2009 at 5:02 am. Reason: Keep It On The Site - Do not post asking for an answer to be sent to you via email or PM.
Similar Threads
Reputation Points: 8
Solved Threads: 0
Newbie Poster
suganthan901307 is offline Offline
1 posts
since Nov 2009
Nov 3rd, 2009
-7
Re: Give me the explanation for this output
the output you posted is wrong. Here is the correct output. Had you bothered to compile and run that program you would have seen it too.

text Syntax (Toggle Plain Text)
  1.  
  2. The contents of the array are :
  3. 1 5 0
  4. 2 4 -2
  5. 3 3 0
  6. 4 2 2
  7. 5 1 4
Last edited by Ancient Dragon; Nov 3rd, 2009 at 10:28 pm.
Sponsor
Team Colleague
Featured Poster
Reputation Points: 5608
Solved Threads: 2282
Retired and Enjoying Life
Ancient Dragon is offline Offline
21,953 posts
since Aug 2005

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Beginner C++
Next Thread in C++ Forum Timeline: compiling multiple files using visual c++





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC