Arrays | Sololearn: Learn to code for FREE!

+1

Arrays

I need to make 3 functions: one to fill in an array another one is to print that array and the last one is to indicate how many values of that array are bigger than 32. Anyone able to help?

4/11/2019 6:13:46 AM

Nabster

5 Answers

New Answer

+2

Nabster What are you waiting for? Write it down ! Without showing your effort you are unlikely to get help.

+1

Nabster And in those 3 hrs you didn't tried to search the net for how to do it ? I will help you if you can show a working code without functions. Else wait someone eager (there are many here) to provide full solution will surely give you the code.

+1

~ swim ~ here's the code I thought of without functions. #include<iostream> using namespace std; int main() { int n,cont=0; cout<<"How big is the array? "<<endl; cin>>n; cout<<"Insert the values of the array: "<<endl; int v[n]; for(int i;i<n;i++) { cin>>v[i]; if(v[i]>32) { cont++; } } for(int i;i<n;i++) { cout<<v[i]; } cout<<"There are "<<cont<<" values that are bigger than 32"<<endl; return 0; }

+1

Nabster It's not a working code. The way you have constructed your array is illegal in C++. First learn how to create dynamic arrays in C++. variable i in for loop is not initialized, it contains garbage value, as a result your loop may never run. First get the above errors fixed, then we will talk about functions.

0

I have and spent 3 hours trying to figure this apparently simple problem but I just can't find the solution. My idea was to make a function to fill the array, return the array then make another function to get that array and output it then make another function that gets it and checks if every value of the array is greater than 32