+ 9
Help me please. I want to print all the inputs from user. But it does not happening. What is my mistake?
7 Answers
+ 4
Use the 'for' loop for taking input from the user and storing the data... and then again use the for loop to print the elements of the array...
I'm attaching your code with some corrections... do check it out...
https://code.sololearn.com/cEDTzK7JCS0z/?ref=app
+ 8
Thank you so much Shubhanshu
+ 6
Hi Yamin Mansuri
In your current code, only one array input will be accepted. It will be in arr[0]
This is because the variable a is uninitialized and as a result defaults to 0.
I suggest you revisit the course, specifically arrays : https://www.sololearn.com/learn/CPlusPlus/1625/?ref=app
And loops: https://www.sololearn.com/learn/CPlusPlus/1616/?ref=app
What you will want to do is to create a loop to take multiple inputs (cin) from the user and then use another loop to print (cout) the array contents to the console.
+ 4
Use this đ to print all inputs from user :
#include <iostream>
using namespace std;
int main()
{
int a;
int arr[5];
for(a=0;a<5;a++)
cin >> arr[a];
for(a=0;a<5;a++)
cout<<"\t"<<arr[a];
return 0;
}
+ 3
Hi my suggestion is use loop statements
+ 1
to unterstand given program
0
Hi