| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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; } } } |
|
#2
|
|||
|
|||
|
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... |
|
#3
|
|||
|
|||
|
Thank you
Thank you for your help, much appreciated
Scarpetta |
![]() |
| Viewing: Dev Articles Community Forums > Programming > C/C++ Help > Help a newbie c++ |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|