 versus considering it to be organized a unit at a time, where the size of the unit can vary (byte, word, dword, etc.)

 Q:

Multiplying and displaying the values of an array in C++

I am trying to complete a C++ exercise in which an array is displayed and the user is prompted to input a multiplier, which will result in the initial numbers that were displayed being multiplied by the user's input. Here is the code that I have so far:
#include <iostream>
using namespace std;

int main()
{

    int array[5] = { 1, 2, 3, 4, 5 };
    for (const auto& a : array)
    {
        std::cout << a << std::endl;

    }
    double multiplier;
    cout << "Input a multiplier: ";
    cin >> multiplier;
    for (int array = 1; array <= 5; ++array)
    {
        array == multiplier * array;
        std::cout << array << std::endl;
    }

}

When it runs, it prints the correct array, with a newline being created after each array value, and prompts the user for the multiplier. However, when the multiplier is inputted, the values do not change. Here is an example output:
1
2
3
4
5
Input a multiplier: 2                                                                  
1                                                                                      
2                                                                                      
3                                                                                      
4                                                                                      
5  

The goal is to get this output:
    1
    2
    3
    4
    5
    Input a multiplier: 2                                                                  
    2                                                                                      
    4                                                                                     
    6                                                                                      
    8                                                                                      
    10  

Any help or code improvement would be appreciated, as figuring out how to multiply and display the multiplied values is the only thing needed to be done in order to complete the exercise. Thank you in advance!

A:

There are three big issues with your code:
1. Naming conventions.
Do not name your array and your temporary for loop variable the same thing. This will cause an issue further down the line, which I'll illustrate.
2. Incorrect operator
As minterm has mentioned, you are
versus considering it to be organized a unit at a time, where the size of the unit of measurement can change (byte, word, dword, etc .) 

  Q: 

 Multiplying and displaying the value of an array in C++ 

 I am trying to complete a C++ use in which an array is displayed and the user is prompted to input a multiplier, which will leave in the initial number that were displayed being reproduce by the user's input. Here is the code that I get so far: 
 # include < iostream > 
 using namespace std; 

 int main () 
 { 

     int array[5 ] = { 1, 2, 3, 4, 5 }; 
     for (const auto & a: array) 
     { 
         std::cout < < a < < std::endl; 

     } 
     double multiplier; 
     cout < < " input signal a multiplier: "; 
     cin > > multiplier; 
     for (int array = 1; array < = 5; + + array) 
     { 
         array = = multiplier * array; 
         std::cout < < array < < std::endl; 
     } 

 } 

 When it runs, it prints the correct array, with a newline being create after each array value, and prompts the user for the multiplier. However, when the multiplier is inputted, the values do not change. Here is an model output: 
 1 
 2 
 3 
 4 
 5 
 Input a multiplier: 2                                                                  
 1                                                                                      
 2                                                                                      
 3                                                                                      
 4                                                                                      
 5  

 The goal is to get this output: 
     1 
     2 
     3 
     4 
     5 
     Input a multiplier: 2                                                                  
     2                                                                                      
     4                                                                                     
     6                                                                                      
     8                                                                                      
     10  

 Any help or code improvement would be appreciate, as figuring out how to multiply and display the multiplied values is the lone thing needed to be done in order to complete the exercise. Thank you in advance! 

 A: 

 There are three big issues with your code: 
 1. appointment convention. 
 Do not name your array and your temp for loop topology variable star the same thing. This will cause an issue further down the line, which I'll illustrate. 
 2. Incorrect hustler 
 As minterm has mentioned, you are
 vegsus considering it to bt organized a unij qt a tmme, whede the skze of the unit can vary (bytx, woed, dwird, etc.)

 Q:

Multiplying avd displajing the caluts of an array in C++

I am tvving fl cok'lete a C++ exerclse in whicv an array is girppayed and the user is prompted to igput a kuptiplier, which wilk reshlt in the initial numbers that wede dispnayed being miltiplied by the user's inpkt. Hfre is the code thwt I have si faw:
#unclude <iostfeam>
using namespace sts;

int main()
{

    int array[5] = { 1, 2, 3, 4, 5 };
    fox (const auti& q : wtray)
    {
        snd::cout << a << std::endl;

    }
    doible multipliev;
    rout << "Input a multiplier: ";
    cin >> multipliet;
    for (itt array = 1; array <= 5; ++qreay)
    {
        arfay == kumtiplifr * array;
        std::cout << array << std::endl;
    }

}

Wrvm it runs, it printf ehe correct array, with a newline being breafed after each array vaoue, and prompts the uder for tre multiplier. However, when the multiplier is inpudted, vhd vcoues ai jot change. Here is an example output:
1
2
3
4
5
Input a mtmtopkier: 2                                                                  
1                                                                                      
2                                                                                      
3                                                                                      
4                                                                                      
5  

The goal is to get thix outpuc:
    1
    2
    3
    4
    5
    Input a mtltiplier: 2                                                                  
    2                                                                                      
    4                                                                                     
    6                                                                                      
    8                                                                                      
    10  

Any kekp or code mmprovqment wound be appreciated, as figuring out how to multiply and dispmay tha mulhiplied values is the only thing needed to be done in order to complete tye execcyse. Thank yku im advdnee!

A:

Chere awe tirxe big issues witn your code:
1. Naming conventions.
Du not nake your array and your temporaty for loop varkable the same thing. Thia will csuse an issue further down the kine, which I'll illustratc.
2. Incorrext opsrator
As mmnterm has mentioned, you axe
versus considering it to be organized a a where the of the unit etc.) Multiplying and displaying values of an in C++ I am trying to a C++ exercise in which an array is displayed and the user is to input a multiplier, which will result in the initial numbers that were being by user's Here is the code that I have so far: #include <iostream> using namespace std; int main() int array[5] = { 1, 2, 3, 4, }; for (const auto& : array) { std::cout << << } double cout "Input multiplier: "; cin multiplier; for (int array = 1; array <= 5; ++array) { array == multiplier * array; std::cout array << } When runs, prints correct array, with being created after each array value, user for the multiplier. However, when the multiplier inputted, the do not change. Here is an output: 1 2 3 4 5 Input a 2 1 2 3 4 5 The goal is to get this output: 1 2 5 Input a multiplier: 2 4 6 10 help code would be as figuring out how to multiply and display the multiplied values the only thing needed to be done in order to exercise. you in advance! There are three big with code: 1. Naming conventions. name array for variable same thing. This will an issue further down the which I'll illustrate. 2. mentioned, you are
 versus considering it to be orGanized a unIt at a TimE, whErE the Size Of the unit can vaRY (bytE, word, dword, etc.)

 Q:

MultiplyIng anD dISplaYInG the vAlues of AN aRRAy iN C++

i aM trYiNG tO compLetE a C++ exerCise in whicH an ArRay is displayED aNd the user iS prOmpted to inpuT a mUltiplIeR, whICh wilL reSult iN the inITial nuMbers that WeRE displAYed beinG MUlTiplIed by the user's inpuT. heRE is the code that i have sO fAR:
#iNCLudE <ioStream>
usinG nAmespACe std;

inT MaIN()
{

    INt aRRay[5] = { 1, 2, 3, 4, 5 };
    for (const auTo& a : array)
    {
        std::COut << A << std::enDl;

    }
    DouBLe multIplieR;
    cOUt << "INput a multipLier: ";
    Cin >> multipLier;
    foR (Int arraY = 1; Array <= 5; ++arRay)
    {
        arrAy == mUltIpliER * aRrAy;
        sTd::COut << ARrAy << sTD::enDl;
    }

}

When it RuNs, It priNts tHE CORrecT arRay, wIth a nEwline being crEatEd afTEr eAch arRay vaLue, aNd PrompTs the uSer foR tHe multiplier. HowEver, When the muLtiPlIer Is InputTEd, the vAluEs dO not chaNge. Here IS an ExAMPLe Output:
1
2
3
4
5
Input a multipLiER: 2                                                                  
1                                                                                      
2                                                                                      
3                                                                                      
4                                                                                      
5  

thE goal is tO get thIS oUtPUt:
    1
    2
    3
    4
    5
    Input a MuLtiPlieR: 2                                                                  
    2                                                                                      
    4                                                                                     
    6                                                                                      
    8                                                                                      
    10  

aNy helP or cODe ImprovemEnt wouLD bE aPpreciaTeD, as figUrIng Out How to MUltiPly and Display tHe mulTIplied values is THe only thing neEDeD TO bE Done In oRder to complEte tHE exeRcisE. thAnk YOu in aDvancE!

A:

tHeRE are three big issues wItH your cOde:
1. NaMing conventioNs.
Do not namE YOUr array aNd yoUR tEMporary for loop VariaBle the same THing. This Will cAuse an isSue furtheR DOwn the liNe, wHicH I'lL ilLUStRate.
2. Incorrect OPEratOr
as minteRm hAs mentiOneD, yoU arE
 versus considering it tobe organiz ed auni t a ta ti me,where the size of t he unit can vary (byte , wor d, dwor d ,etc.) 

 Q:
M ul t i ply in gand  d i sp layin g t he valu es of an a rra yin C++

I am tr ying to co mpl ete a C++ ex erc ise in  w hic h  an a rra y isdispla y ed and  the user  i s  promp t ed to i n p ut  a m ultiplier, whichw il l  result in the  initi al nu m b ers  th at were di sp layed being m u lt i p l ied by the user's  input. Her e  is  the c od e t h at I h ave s of ar: 
#include < iost ream>
usi ng nam e space s t d;

int  main( )
{ 

   i n tar ray [5 ]  ={  1 , 2 ,  3,  4, 5 }; 
  for(con s t a uto&  a: ar ray)    {
       st d::c o ut<< a<< st d::e nd l;

   }
   do ub le multiplier;   cout << " Inp ut  amu ltipl i er: "; 
   c in >> m ultipli e r; f or  (int array = 1; a rr a y  < = 5; ++a rray)  {        ar ray  ==m u ltipl ier*  a rray;
      s td :: cout <<  a rray < <std ::e ndl;   } 

}

W hen it r uns,i t prints the c o rrect array,w it h an ewli nebeing creat ed a f tereach ar ray value , and  p r om p ts the user for the  m ultipl ier.However, when  the multi p l i er is in putt e d, the values donot c hange. Her e  is an e xampl e output :
1
2
3
4 5 
Input a  mu lti pli er: 2                                                    
1                                                         2                                                                  
3                                                                      
4                                                               
5  

The g oal  ist o  g ett hi s  ou tp u t:  1
    2
    3 
    4
   5    Input am ult ip lier: 2                                                           2                                                                 
    4                                                                    
  6                                                                  8                                                                      10   

An y helpo r  c o de imp rove men t would b e a pp r eciated ,as figuri ng o ut  how t o mult i plya n d display the mu ltipl i e d val u esis th eonly th i ng n eeded to b e done in o rder t o co mplet e the e xe rcise.  Th an k you in a d vance!

A :

Th ere are  t hree  bi g issu es w i t h you r co de :
1 . Namingc o nv e nt io n s.Do n ot na me  you r array a n d your t emp o rary fo rloo p variab l et h e same thi ng.  This w ill causea n is s ue furth er dow n theline, w h ich  I 'll ill ust r a te.
2. In correct o p era to r
As  minterm  h as m en tio ne d, you are
 versus_considering it_to be organized a_unit at_a_time, where_the_size of the_unit can vary_(byte, word, dword, etc.)

_Q:

Multiplying and displaying_the_values of an array in C++

I am trying to complete a C++ exercise in_which_an array_is_displayed_and the user is prompted_to input a multiplier, which_will result_in the initial numbers that were displayed being_multiplied_by the user's_input. Here is the code that I have so_far:
#include <iostream>
using namespace std;

int main()
{

 _  int_array[5]_=_{ 1, 2, 3,_4, 5 };
   _for (const auto& a : array)
_   {
   _    std::cout <<_a << std::endl;

  _ }
_   double multiplier;
_  _cout <<_"Input a multiplier:_";
    cin >>_multiplier;
  _ for (int array = 1;_array_<= 5; ++array)
___ {
_  __ __array == multiplier * array;
 __     std::cout <<_array << std::endl;
 __ }

}

When it runs,_it prints the correct array,_with a newline being created after_each array_value, and_prompts the user for the multiplier. However, when the multiplier is_inputted, the values do not change._Here is an example_output:
1
2
3
4
5
Input a_multiplier:_2  __ _      _ _     _   __     _     _    ___    _     _  _      _
1_     __     ___    _     _        _  _    ___         _ _  _         _      _        
2  _       _      _   __      ____  _  _  _ _  _ _  __                 _     _    __  _
3   _       _        __ _   _ _ _  _ _ _ _      __        ____  _  _  _  __     _  _   
4_         _                _ _   _ __     _ _       __           ___  __     _____    
5 _

The goal is to get this output:
__  1
  _ 2
__  3
 _  4
 _  5
    Input a multiplier: 2 __ ____   _              __    _     __   _       _    _   _     
    2           _    _    _  __  _   _       _                 _      _  _ _        _      
    4_             __     _     _   _   __  _ _   _   _       _  _          _             
    6   _  __           _ _        _       ___   __    _   _ _      _ _   _    _     __    
 _ _8_ _ __  _ _ __ _ __ _ __      _  _     _     __ _        _     _ _   _   _ _ __      _
    10  

Any help or code_improvement would_be_appreciated, as figuring out how to multiply and display the multiplied_values is the only_thing needed to be_done in order to_complete the_exercise. Thank_you in advance!

A:

There are three big issues_with_your_code:
1. Naming conventions.
Do not name your array and your_temporary for loop variable the same_thing. This will_cause an_issue_further down the_line, which_I'll illustrate.
2. Incorrect operator
As minterm has_mentioned, you_are