+ 9

Help me please. I want to print all the inputs from user. But it does not happening. What is my mistake?

https://code.sololearn.com/ciBQFn36HyZv/?ref=app

8th Oct 2018, 9:46 AM
Yamin Mansuri
Yamin Mansuri - avatar
7 odpowiedzi
+ 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
8th Oct 2018, 10:04 AM
Shubhanshu
Shubhanshu - avatar
+ 8
Thank you so much Shubhanshu
8th Oct 2018, 1:30 PM
Yamin Mansuri
Yamin Mansuri - avatar
+ 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.
8th Oct 2018, 10:07 AM
jay
jay - avatar
+ 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; }
5th Nov 2018, 8:34 AM
Amruta
Amruta - avatar
+ 3
Hi my suggestion is use loop statements
8th Oct 2018, 10:01 AM
mansoor
mansoor - avatar
+ 1
to unterstand given program
6th Nov 2018, 3:51 PM
Vikraman M
Vikraman M - avatar
0
Hi
8th Oct 2018, 1:47 PM
mansoor
mansoor - avatar