C/C++ Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
User Name:
Password:
Remember me
 
Go Back   Dev Articles Community ForumsProgrammingC/C++ Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Display Modes
 
Unread Dev Articles Community Forums Sponsor:
Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old June 1st, 2004, 07:07 AM
Scarpetta Scarpetta is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 Scarpetta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Help a newbie c++

Hi folks,
I am trying to write a program which allows the user to type in numbers into two single dimension arrays and then multiply the elements of the arrays. The program compiles without errors but the output is incorrect. (I have outlined the program below) Please help !

//multiply the elements of two arrays
#include <iostream>
using namespace std;

void main()
{
int digit[5];

cout <<" please enter five numbers" <<endl;

for (int index =0; index <5; index++)

{
cin >> digit[index];


int ray[5];

cout <<" please enter five numbers for array two" <<endl;


for (int i = 0; i <5; i++)
{

cin >> ray[i];

cout << "List the numbers" << digit[0]* ray[0] << digit[1] * ray[1] << digit[2] * ray[2] << digit[3] * ray[3] << digit[4] * ray[4] << digit[5] * ray[5] << endl;
}
}
}

Reply With Quote
  #2  
Old June 3rd, 2004, 12:46 AM
ayan ayan is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Location: cebu
Posts: 8 ayan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
like this?
Code:
 #include<iostream>
 main(){
 	int d[5];
 	cout<<"please enter five numbers for array one"<<endl;
 	for(int i=0;i<5;i++) cin>>d[i];
 	int r[5];
 	cout<<"please enter five numbers for array two"<<endl;
 	for(int i=0;i<5;i++) cin>>r[i];
 	cout<<"list the numbers:  ";
 	for(int i=0;i<5;i++) cout<<d[i]*r[i]<<"   ";
 	cout<<endl;
 }
 

if not, sorry...

Reply With Quote
  #3  
Old June 3rd, 2004, 12:14 PM
Scarpetta Scarpetta is offline
Registered User
Dev Articles Newbie (0 - 499 posts)
 
Join Date: May 2004
Posts: 2 Scarpetta User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thank you

Thank you for your help, much appreciated

Scarpetta

Reply With Quote
Reply

Viewing: Dev Articles Community ForumsProgrammingC/C++ Help > Help a newbie c++


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway