Answer to Question #18677 in C++ for kenneth

Question #18677
write a program that will use a vector to store a set of decimal values .the size of the vector is up to you.A function should be called that will allow a user to enter the values for the vector.next you should display to the user the size of the victor ,how many element its hold .next another function should be called that will output the element of the vector(3 on each line with 5 spaces between).
1
Expert's answer
2012-11-15T07:39:12-0500
# include <iostream>
# include <vector>
using namespace std;

vector <double> A(20);
void add(int i,double ch){// add a double
A[i]=ch;
}
void out(int len){// print all
int triple(0);
while (len>=0){
& triple++;
cout<<A[len]<<" quot;;
if (triple%3==0) {triple=0; cout<<endl;}
len--;
}
cout<<"End of vector"<<endl;
}
int main(){
double ch(1);
int i(0);
cin>>ch;
while (ch!=0){
add(i,ch);
i++;
cin>>ch;
}
i--;
out(i);

system("PAUSE");
return 0;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS