Help

#include<iostream>
using namespace std;
int main()
{
int const n=5;
int k=0,i,B[n],R[n]={3,-2,6,1,2};
for(i=0;i<n;i++)
{
if(R[i]>3)
{
B[k]=R[i];
k=k+1;
}
}
for(i=0;i<k;i++)
{
cout<<" "
<<B[i];
}
cout<<endl;
return 0;
}
why doesnt this work ?
I want to make a new vector from the numbers that are bigger than 3 from Rm
Last edited on
on line 5, it is const int n and not int const n
still wont work there are no syntax errors but still it doesnt make what im wanting to
You want the program to populate a new array B by iterating through an existing array R, so wherever an element in the array R is found to be greater than 3,it gets appended to B, right? The output is 6. Isn't that what you are trying to do?
LOL Matri X it was alright i just thought i have more numbers greater than 3 and not just one so sorry for bothering it was right from the beginning i just was wondering how cant it work
Topic archived. No new replies allowed.